Webdriver Page对象类获得了更多方法

Webdriver Page对象类获得了更多方法,webdriver,selenium-webdriver,pageobjects,Webdriver,Selenium Webdriver,Pageobjects,我为登录页面编写了页面对象类,用于测试web、iphone和平板电脑的UI外观。对于每个验证,我都编写了一个方法来返回该元素的cssValue或text 增加在单个类中定义的lot方法的编写。有没有办法减少页面对象类中声明的方法数 例如: public String getBannerCssValue(String cssValue){ return getCssValue(driver.findElement(banner), cssValue); } public Strin

我为登录页面编写了页面对象类,用于测试web、iphone和平板电脑的UI外观。对于每个验证,我都编写了一个方法来返回该元素的cssValue或text

增加在单个类中定义的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"); 
}

我认为你应该以实际使用这些getter的方式为指导

在我的代码中,我经常将多个控件读入单个对象:页面上的用户数据读入用户对象。因此,我有一个单一的getter

在其他上下文中,在我没有(或不需要)对象的情况下,我有单独控件的单独getter

有一些或所有这些获得者的二传手吗?如果是这样,考虑将一个GETT/SETTER对合并成一个函数。我在我的博客上写过:


我刚刚遇到了“使用枚举模式的页面对象”,听起来很有趣。对这种方法有什么反馈吗?你需要所有这些方法吗?如中所示,您实际使用的是各种
*getCssValue
方法吗?不是每个对象都有一个方法,而是只有3个方法,getCssValue、getAttributeValue、getTextValue,并使用不同的对象值调用它们。我更希望web元素有一些注释映射,并有直接使用web元素的操作方法。取而代之的是,getter使用的POM使用的是@KingArasan@TestAutomationEngr在page对象之外,我们不应该公开Web元素。所以测试类不知道Web元素。