Java selenium中的页面对象模型和页面工厂有什么区别?
看起来页面对象模型和页面工厂在做同样的事情。所以我很困惑Java selenium中的页面对象模型和页面工厂有什么区别?,java,selenium,testing,selenium-webdriver,automated-tests,Java,Selenium,Testing,Selenium Webdriver,Automated Tests,看起来页面对象模型和页面工厂在做同样的事情。所以我很困惑 IpmObjectInitializer initialize = new IpmObjectInitializer(driver.getWebDriver()); //初始化BatchCreationPageFactory类中的元素 batchCreationPageFactory = initialize.getBatchCreationPageFactoryObj(); 页面对象是一个表示网页并包含功能和成员的类 public
IpmObjectInitializer initialize = new IpmObjectInitializer(driver.getWebDriver());
//初始化BatchCreationPageFactory类中的元素
batchCreationPageFactory = initialize.getBatchCreationPageFactoryObj();
页面对象
是一个表示网页并包含功能和成员的类
public class LogInPage
{
private WebElement userName;
private WebElement password;
public LogInPage() {
}
public void locateElements() {
userName = driver.findElement(By.id("userName"));
password = driver.findElement(By.id("password"));
}
public void doLogIn() {
userName.sendKeys("qwe");
password.sendKeys("123");
}
}
Page Factory
是一种在创建页面对象实例时初始化页面对象中要与之交互的web元素的方法
public class LogInPage
{
@FindBy(id="userName")
private WebElement userName;
@FindBy(id="password")
private WebElement password;
public LogInPage() {
PageFactory.initElements(driver, this); // initialize the members like driver.findElement()
}
public void doLogIn() {
userName.sendKeys("qwe");
password.sendKeys("123");
}
}
页面对象模型(POM)
一,。。POM是一种基于页面分离selenium代码的设计模式
例如:为登录页面创建一个单独的java类,为主页创建另一个类等
二,。。页面对象模型是在测试框架中表示应用程序的一种方法。对于应用程序中的每个“页面”,您都会创建一个页面对象来引用“页面”
页面工厂
一,。。高级概念(POM+新功能)或