我到页面对象模式下面的链接和概念是好的,页对象模式DESGIN
https://code.google.com/p/selenium/wiki/PageObjects
这里是我的疑问:
public LoginPage typeUsername(String username) {
driver.findElement(usernameLocator).sendKeys(username);
return this;
}
public LoginPage typePassword(String password) {
driver.findElement(passwordLocator).sendKeys(password);
return this;
}
public HomePage submitLogin() {
driver.findElement(loginButtonLocator).submit();
return new HomePage(driver);
}
以上硒呼叫包裹着一些功能我们在测试用例或任何页面级函数中调用这些函数,如下所示:
public HomePage loginAs(String username, String password) {
typeUsername(username);
typePassword(password);
return submitLogin();
}
我的疑问是:为什么我们不能直接调用sendkey或在整个项目中每次提交或点击。只有一行代码再次用我们自己的函数包装,这将需要更多的时间来运行代码。
是否有任何性能问题?