GooglePage.java
Testcode:public class GooglePage extends MyDriver{ @FindBy(how = How.NAME, using = "q") private WebElement searchtext; public
GooglePage
() { super(); System.out.println("cool stuff!"); } public void typeText(){ searchtext.sendKeys("abc"); } }
public class TestCode{
public TestCode(){
GooglePage googlePage = PageFactory.initElements(driver, GooglePage.class);
//
We need to use PageFactory.initElements(driver, GooglePage.class)
// instead of "new GooglePage()
since the GooglePage defines the WebElement using @FindBy.
}
public void testCase1(){
googlePage.typeText();
....
}
}
No comments:
Post a Comment