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.
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();
}
}