【问题标题】:How to get the type of element / tag type in selenium c#如何在selenium c#中获取元素/标签类型的类型
【发布时间】:2017-10-30 16:51:34
【问题描述】:

比如说我有一个标签:

<a class = "fp-anchor fp-forgot-password pull-right" href = "/Account/ForgotPassword">Forgot Password?</a> == $0

我正在尝试获取元素的类型,我的意思是应该是锚a 标记。或者更准确地说,我需要确定这是否是一个超链接。 类似的,

Driver.FindElement(By.Id("someid")).<whatever selenium webdriver function to identify what type of element it is>

类似地,如果它是一个输入标签,比如说

<input type="text"..../>

它应该将标签标识为input 类型。

任何建议都会有很大帮助。

【问题讨论】:

    标签: c# jquery html selenium


    【解决方案1】:

    是的,您可以使用.TagName; 属性获取标签名称

    例如

    string tagname = Driver.FindElement(By.Id("someid")).TagName;
    

    【讨论】:

    • 函数 GetTagName 没有出现在我的案例中。
    • @BishwaroopChakraborty,试试这个TagName 例如string tagname = Driver.FindElement(By.Id("someid")).TagName 让我知道它是否在 C# 中工作
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-11-17
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-11-30
    • 1970-01-01
    相关资源
    最近更新 更多