![](/img/trans.png)
[英]Selenium WebDriver - What is the way to find checkbox with @FindBy annotation?
[英]Selenium WebDriver can't find element by @FindBy annotation
我想找到这个元素
driver.findElement(By.className("name")).findElement(By.tagName("a"));
有没有办法使用@FindBy
注释?
由于您要在具有“ name”类的元素内寻找“ a”标签,因此请尝试通过XPath或CSS选择器将它们组合:
@FindBy(xpath = "//*[@class = 'name']/a")
private WebElement nameLink;
要么
@FindBy(css = ".name > a")
private WebElement nameLink;
我在硒中测试了多个FindBys
批注,但有时使用TageName
和Name
不能正常工作!
经常查找List<WebElement>
使用driver.findElement(By.name("...."))
进行过滤。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.