我已经浏览了很多博客和网站以获取关于POM(Page Object Model)的更多信息。然而,一些博客的使用提供了与@FindBy例子PageFactory用于获取的Web元素和一些博客有创造与WebElement书面和发现使用findElement()方法元素的方法下面给出:Selenium WebDriver @FindBy和findElement()的区别
1. @FindBy(id="clickhere")
WebElement linkClickHere;
public classconstructor(WebDriver driver){
return PageFactory.initElements(driver, classname.class);
}
2. public static WebElement lnk_MyAccount(WebDriver driver){
return driver.findElement(By.id("clickhere"));
}
我明白使用工厂,我们在执行脚本之前获取网页的所有元素,从第二点开始,它在脚本执行时查找元素,如果我错了,请纠正我。
现在,我们应该使用哪一个?这其中最好的是哪一个?这两个之间有什么区别吗?这两个有什么优势和劣势?
我很感激你的投入....
看看下面的主题:1. http://stackoverflow.com/questions/17819905/selenium-difference-between-findby-and-webelement-findelement 2. http://stackoverflow.com/questions/ 21723730/when-do-find-attributes-trigger-a-driver-findelement 3. http://stackoverflow.com/questions/17819905/selenium-difference-between-findby-and-webelement-findelement –