我已经为登录页面编写了 Page 对象类来测试 Web、iphone 和平板电脑的 UI 外观。对于每个验证,我都编写了一个方法来返回该元素的 cssValue 或文本。
编写增加了在单个类中定义的 lot 方法。有没有办法减少页面对象类中声明的方法?
例子:
public String getBannerCssValue(String cssValue){
return getCssValue(driver.findElement(banner), cssValue);
}
public String getSmartPhoneLegendText(){
return getElementText(driver.findElement(smartPhoneLegend));
}
public String getSmartPhoneLegendCssValue(String cssValue){
return getCssValue(driver.findElement(smartPhoneLegend), cssValue);
}
public String getTabletLegendText(){
return getElementText(driver.findElement(tabletLegend));
}
public String getTabletLegendCssValue(String cssValue){
return getCssValue(driver.findElement(tabletLegend), cssValue);
}
public String getButtonTextValue(){
return getAttribute(driver.findElement(login), "value");
}
public String getSubmitButtonCssValue(String cssValue){
return getCssValue(driver.findElement(login), cssValue);
}
public String getForgotPasswordCssValue(String cssValue){
return getCssValue(driver.findElement(forgotYourPassword), cssValue);
}
public String getTabButtonTextValue(){
return getAttribute(driver.findElement(tabletSubmit), "value");
}