2017-05-30 155 views
0

例如说我有一个标签作为类型:如何获得元素/标签类型的硒C#

<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类型。

任何建议将是很大的帮助。

回答

1

是的,你可以使用.TagName;财产

例如获得标签名称

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

功能GetTagName oes不会出现在我的情况。 –

+0

@BishwaroopChakraborty,试试这个'TagName'例如'string tagname = Driver.FindElement(By.Id(“someid”))。TagName'让我知道它是否在C#中工作 –