Pageobject ideas to transform small projects

Ideas:
1. Three files
The positioning and operation of a-element has jumped to resultpage
b-result> element inspection
public void checkKeyword(){ //Assert is an assertion operation provided by TestNG, assertEquals (actual value, expected value), to determine whether two values ​​are equal.
Assert.assertEquals(RP_INPT_KEYWORD.getAttribute("value"), "selenium");

c - test file
hsp.openUrl(); //Use the input operation encapsulated by the page to verify whether the value of the search result input box page is selenium
hsp.searchByKeyword("selenium").checkKeyword();//Exit operation using page encapsulation
hsp.close();

For common methods of findby, please refer to the extension directory for details. http://blog.csdn.net/u013840366/article/details/68944845
public void A_AddAllEvent() throws InterruptedException {
//Instantiate the BDPage object
//ListPage page = PageFactory.initElements(driver, ListPage.class);
ListPage bdp = new ListPage(driver);
//bdp call to add event element, then click click
SwitchTo.getWindowHandle(driver);
logger.info("Go to this new event action");
Thread.sleep(5000);
bdp.AddEvent_Link.click();
Thread.sleep(4000);
//bdp调用添加event title,输入内容
SwitchTo.getWindowHandle(driver);
bdp.Event_Input.sendKeys("All-Day Event");
//bdp调用勾选all day event,输入内容,
bdp.AllDay_Input.click();
//bdp调用添加notes,输入内容
bdp.Notes_TextArea.sendKeys("Calendar Note");
//bdp调用添加location,输入内容
bdp.location_TextArea.sendKeys("Calendar Location");
bdp.Save_Input.click();
bdp.Tips_Div.getText();
}

具体的一个小实例如下:
list page
public class ListPage {
/ / Personal Calenar页面添加event按钮
@FindBy(xpath = ".//*[@id='ccTgArea']/div[9]/div[1]/a[1]")
@CacheLookup
public WebElement AddEvent_Link;
// Event详情页面,event subject
@FindBy(name = "title")
@CacheLookup
public WebElement Event_Input;
// Event详情页面,event all day event
@FindBy(id = "eteevent")
@CacheLookup
public
WebElement AllDay_Input;
// Event详情页面,event all day event
@FindBy(id = "notes")
@CacheLookup
public
WebElement Notes_TextArea;
// Event详情页面,event all day event
@FindBy(id = "location")
@CacheLookup
public
WebElement location_TextArea;


// Event详情页面,event all day event
@FindBy(linkText = "Save")
@CacheLookup
public
WebElement Save_Input;
// Event创建后,页面定位提示信息
@FindBy(xpath = "html/body/div[1]/div/div[2]")
@CacheLookup
public
WebElement Tips_Div;
public ListPage(WebDriver driver) {
PageFactory.initElements(driver, this);
}

}

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325763502&siteId=291194637