How do i pass the browser from test to test with Arquillian Drone and Graphene

57 views Asked by At

I'm trying out Arquillian Drone and Graphene and I have the following 2 tests what i want to do is have the second test use the browser from the first tests. but the browser closes after the first test finishes - is there a way to pass the browser to the second test?

 @RunAsClient
    public class Test1 extends Arquillian{

    private final String subscriptionName = "subName";
    private final String subscriptionDescription = "description";

    @Test(dataProvider = Arquillian.ARQUILLIAN_DATA_PROVIDER)
    public void enterSubscriptionName(@InitialPage SubscriptionPage subscriptionPage) {
        subscriptionPage.enterName(subscriptionName);
        assertEquals(subscriptionName, subscriptionPage.getNameFieldValue());
    }

    @Test(dataProvider = Arquillian.ARQUILLIAN_DATA_PROVIDER)
    public void enterSubscriptionDescription( SubscriptionPage subscriptionPage) {
        subscriptionPage.enterDescription(subscriptionDescription);
        assertEquals(subscriptionDescription, subscriptionPage.getDescriptionFieldValue());
    }
}
1

There are 1 answers

0
vins On BEST ANSWER

I would refactor the above test as shown here to use the SubscriptionPage in the second test.

@RunAsClient
 public class Test1 extends Arquillian {

     private final String subscriptionName = "subName";
     private final String subscriptionDescription = "description";

     @Page
     SubscriptionPage subscriptionPage;

     @Test(dataProvider = Arquillian.ARQUILLIAN_DATA_PROVIDER)
     public void enterSubscriptionName() {
         Graphene.goTo(SubscriptionPage.class);
         subscriptionPage.enterName(subscriptionName);
         assertEquals(subscriptionName, subscriptionPage.getNameFieldValue());
     }

     @Test(dataProvider = Arquillian.ARQUILLIAN_DATA_PROVIDER)
     public void enterSubscriptionDescription() {
         subscriptionPage.enterDescription(subscriptionDescription);
         assertEquals(subscriptionDescription, subscriptionPage.getDescriptionFieldValue());
     }
 }