如何找到所提及代码的web元素

时间:2015-07-06 10:36:09

标签: selenium automation

如何在selenium web驱动程序中找到下面提到的代码

中的web元素
<a class="small" onmouseout="delayhidemenu()" true;="" return="" onmouseover="dropdownmenu(this, event, menu1, '120px')" onclick="return clickreturnvalue()" href="#">

    Patient ▾

2 个答案:

答案 0 :(得分:0)

您可以使用xpath,如下所示

//a[@class='small']  

//a[starts-with(normalize-space(text()), 'Patient')]

答案 1 :(得分:0)

如果是C#,您可以使用其中任何一种。

driver.FindElement(By.ClassName("small"));    
driver.FindElement(By.CssSelector("[class='small']"));
driver.FindElement(By.CssSelector("[onclick='return clickreturnvalue()']"));