1

I am new to Selenium and Arquillian framework. I am trying to implement Page Object Model. Webdriver browser capabilities are saved in arquillian xml file.

I am using TestNG and created the following classes:

public class Test{
  @Drone
  Webdriver driver;
  @Page
  Login login;
  @Page
  Home home;
  public void createOrderTest(){
    login.navigateURL();
    login.setcredentials();
    home.createOrder();
  }
}

public class Login{
  // Webelements needed in methods below are declared here
  public void navigateURL(){
     driver.get("//url/login.aspx");
  }
  public void setCredentials(){
     // code to enter username, password and click login 
     Graphene.waitAjax().until().element(signIn).is().not().visible();
  }
}

public class Home{
  // Webelements needed in methods below are declared here
  public void createOrder(){
     // code to create order
  }
}

Problem Statement: I am not sure how to navigate between Login and Home pages in code. Once user logs in using Login page methods, how does Webdriver get to use Home page methods to continue the test ?

Error:

Test runs fine with navigateURL and setcredentials methods. However, test fails to access createOrder method as follows:

WARNING: Argument 1 for UpdateTestResultBeforeAfter.update is null. It won't be invoked.
FAILED CONFIGURATION: @BeforeMethod arquillianBeforeTest(public void Test.createOrder() throws javax.mail.MessagingException,java.io.IOException,java.security.GeneralSecurityException)
org.jboss.arquillian.graphene.enricher.exception.PageObjectInitializationException: Can not instantiate Page Object class Home

Please guide me. Thank you.

newuser
  • 307
  • 3
  • 24
  • Questions seeking debugging help ("**why isn't this code working?**") must include the desired behavior, a _specific problem or error_ and _the shortest code necessary_ to reproduce it **in the question itself**. Questions without **a clear problem statement** are not useful to other readers. See: [mcve]. – JeffC Mar 27 '17 at 20:02
  • @JeffC Thanks for the suggestion.I edited my question to make it more readable. – newuser Mar 28 '17 at 16:47

1 Answers1

3

Is the home page a static page? I assume you should not redirect the login page to home page. This should be done by the application itself. That is, end user will access the login page with url. after the all the navigations should be done by the application itself.

@RunAsClient
public class Test extends Arquillian{

  @Drone
  Webdriver driver;

  @Page
  Login login;

  @Page
  Home home;

  public void createOrderTest(){
    login.navigateURL();
    login.setcredentials();

    //you do not need this
    //home = Graphene.goTo(Home.class)

    //use graphene fluent wait API to wait for the page load
    home.createOrder();
  }
}
vins
  • 15,030
  • 3
  • 36
  • 47
  • Application navigates to home page after user logins. I have removed the Graphene.goTo statement and added wait until login button is not visible, but it didn't help. I tried removing @Location annotation in Home page. Error still persists. I edited code to reflect my new changes. – newuser Mar 30 '17 at 17:14
  • Locator of an object inside Homepage is incorrect due to which execution fails to continue. Changed the className of object and it worked fine. Thanks. – newuser Apr 03 '17 at 14:15