Selenium Page Object Model-FindAll annotation
2017-04-01 15:17
337 查看
可以用FindBy注释来代替driver.findelement(By x).
FindBy的10种定位元素的方法。
//定义一个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种定位元素的方法。
相关文章推荐
- Page Object Model (Selenium, Python)
- Page Object Model (Selenium + Python)(三)
- Page Object Model (Selenium, Python)(一)
- Selenium的PO模式(Page Object Model)|(Selenium Webdriver For Python)
- Selenium的PO模式(Page Object Model)[python版]
- selenium page object model
- Selenium的PO模式(Page Object Model)[python版]
- Selenium的PO模式(Page Object Model)|(Selenium Webdriver For Python)
- Page Object Model (POM) & Page Factory in Selenium: Ultimate Guide
- Python+Selenium框架设计--- Page Object Model
- 如何解决Selenium中"Cannot find function addEventListener in object [object HTMLDocument]"的错误
- 浅析selenium的page object模式
- selenium设计模式之PageObject
- Selenium PageObject实例
- find out all attributes of an object
- Selenium的PageFactory & PageObject 在大型项目中的应用
- Dbflow:Model object: xxxx is not registered with a Database. Did you forge an annotation?
- selenium+java+testNG+pageObject深入理解自动化测试框架
- selenium+java+testNG+pageObject深入理解自动化测试框架
- Selenium2(java)页面对象模型(Page Object) 八