java - PageFactory. How to separate page elements and steps -


i'm trying use pagefactory methods , separate classes elements , methods. instance have class page elements:

public class loginpageelements extends abstractpage  {  @findby(id = "rwoauthusername") public webelement login;  @findby(id = "rwoauthpassword") public webelement password;  @findby(id = "rwoauthlogin") public webelement submit;   public loginpageelements (webdriver driver){     super(driver); } 

and class page methods:

public class loginpagesteps {  private loginpageelements elements;  @step public void filllogin(string value){     elements.login.clear();     elements.login.sendkeys(value); }  @step public void fillpassword(string value){     elements.password.clear();     elements.password.sendkeys(value); }  @step public void submittheform(string value) {     elements.submit.click(); } 

on previous page cause method visiting login page , initializing required elements:

    public loginpageelements clickloginbutton(){         loginbutton.click();         return pagefactory.initelements(driver, loginpageelements.class); } 

but thing can't write test like:

@beforetest public void testsetup(){     driver = drivermanager.getdriverfor("ff");     cnbloginpage oncnbstartpage = pagefactory.          initelements(driver, cnbloginpage.class);     oncnbstartpage.             clickloginbutton().             filllogin(login). 

due fact clickloginbutton() returns loginpageelements class, filllogin() in loginpagesteps class.

could please tell me how return elements , classes here?


Comments

Popular posts from this blog

java - Custom OutputStreamAppender not run: LOGBACK: No context given for <MYAPPENDER> -

java - UML - How would you draw a try catch in a sequence diagram? -

c++ - No viable overloaded operator for references a map -