我正在尝试Arquillian Drone和Graphene,我有以下2个测试,我想做的是让第二个测试使用第一次测试的浏览器。但是在第一次测试结束后浏览器关闭了 - 有没有办法将浏览器传递给第二次测试?
@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());
}
}
答案 0 :(得分:0)
我将重构上面的测试,如此处所示,在第二次测试中使用SubscriptionPage。
@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());
}
}