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
Post a Comment