java - Is there a different way to use methods of another class? -
i fixed it. extended abstractpage
methods are. @ first test class must have singular no-argument constructor. realized in @before driver variable , startup variable made problems after removed , called open chromedriver()
method , openhomepage
method eclipse happy , allowed me run tests , remove part had call class method. help.
package seleniumtests.qa.com; public class testforpage { private webdriver driver; @before public void setup() { abstractpage startup = new abstractpage(driver); driver = startup.openchromedriver(); onregistrationpage = new registrationpage(driver); onregistrationpage.openhomepage(driver); } @test public void register() { onregistrationpage.clickon(onregistrationpage.registration_link); assertequals(onregistrationpage.geturl(),"http://demoqa.com/registration/"); // write first name** onregistrationpage.type(onregistrationpage.first_name_input, "user"); // write last name onregistrationpage.type(onregistrationpage.last_name_input, "dev"); // click marrital status onregistrationpage.clickon(onregistrationpage.marital_status_button); // click hobby onregistrationpage.clickon(onregistrationpage.hobby_button);
this how code looks now.
public class testforpage extends abstractpage { public testforpage() { } @before public void setup() { driver = openchromedriver(); openhomepage(driver); } @test public void register() { clickon(registration_link); assertequals(geturl(),"http://demoqa.com/registration/"); // write first name** type(first_name_input, "user"); // write last name type(last_name_input, "dev"); // click marrital status clickon(marital_status_button);
if want call method located in registrationpage
class need have instance of compiler knows clickon
method calling.
you can without instance making method static
, can call registrationpage.clickon, changing static has other implications should read on.
the other solution make registrationpage parent class/interface , have lower class inherit it, can call clickon
; doesn't make sense have test class inherit non-test class.
Comments
Post a Comment