这有效:
@CacheLookup
@FindBy(id = "title")
private WebElement title;
但我正在尝试这样的事情:(它不起作用)
@CacheLookup
@FindBy(By.id("title"))
private By titleBy;
非常感谢任何帮助。 谢谢
答案 0 :(得分:0)
我认为你正在寻找类似的东西:
@FindBy(how = How.NAME, using = "q")
private WebElement searchBox;
答案 1 :(得分:0)
首先,(来自你的评论)
不建议使用
webDriver.findElement(By.id("xxxx")), or webDriver.findElement(element)
当您使用Page factory时。只需直接执行操作,并通过 PageFactory.initElements()方法处理webelements布线。
请check this了解详情。
来到你的问题,
@FindBy(By.id("title"))
不存在。如果您需要替代方法,请尝试olyv。
建议的如何类