您的位置:首页 > 移动开发 > Objective-C

Selenium Page Object Model-FindAll annotation

2017-04-01 15:17 337 查看
可以用FindBy注释来代替driver.findelement(By x).

//定义一个element
@FindAll({@FindBy(xpath = "yourxpath")})
public WebElement; resultElements;


//一次定义多个elements
@FindAll({@FindBy(xpath = "yourfirstxpath"),@FindBy(xpath = "yoursecondxpath"),@FindBy(xpath = "yourThirddxpath")})
public List<WebElement> resultElements;


//一个项目中的例子
package com.perficient.test.cat.com.reg.basepages;

import java.util.List;

import org.openqa.selenium.WebElement;
import org.openqa.selenium.support.FindBy;

public class Augers{

//Labels for New Products and Rental Products
@FindBy(xpath = "//*[@class='filters']/li/input")
public List<WebElement> listOfLabelsOfBrowserInventory;

//Augers title
@FindBy(xpath="//div/h2")
public WebElement titleOfAugers;

//currency dropdown
@FindBy(xpath="//div/select[@name='currency']")
public WebElement dropdownOfCurrency;

//MSRP disclaimer
@FindBy(xpath="//div/select[@name='currency']")
public WebElement MSRPDisclaimer;

//Availability Statement
@FindBy(xpath="//div[@class='availability-statement']")
public WebElement Availabity;
}


FindBy的10种定位元素的方法。

内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  selenium findby