我如何通过浏览器从测试到使用 Arquillian Drone 和 Graphene 进行测试
How do i pass the browser from test to test with Arquillian Drone and Graphene
我正在试用 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());
}
}
我将重构上面的测试,如此处所示,以便在第二个测试中使用 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());
}
}
我正在试用 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());
}
}
我将重构上面的测试,如此处所示,以便在第二个测试中使用 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());
}
}