相关疑难解决方法(0)

查找WebElements,最佳实践

在我们当前的自动化(使用Selenium/WebDriver/Java)中,我们使用@FindBy 非常广泛.例如:

@FindBy(css="a[name='bcrumb']")    protected List<WebElement> breadCrumbLinks;
@FindBy(id="skuError")         protected WebElement skuError;  
@FindBy(className="reducedPrice")  protected List<WebElement> reducedPrice;
@FindBy(partialLinkText="Injinji RUN 2.0")  protected WebElement playButton;
@FindBy(linkText="annual member refund")    protected WebElement annualMemberRefund;
@FindBy(xpath="//li[@itemprop='price']")    protected WebElement productPrice;
Run Code Online (Sandbox Code Playgroud)

根据定义,@FindBy可以使用以下命令定位选择器:using,id,name,className,css,tagName,linkText,partialLinkText和xpath.

最近,我们的前端开发人员建议我们实现一个以'test ='开头的新属性类.我认为这是一个好主意,因为我们可以通过查找文本的模糊来找到WebElements,而不是@FindBy本身使用的值.我的问题是,这将是更好地扩大现有功能@FindByOR,创建搜索,我们在我们的测试中使用WebElements的一种新的方式?

java selenium automation ui-automation selenium-webdriver

10
推荐指数
1
解决办法
1万
查看次数