I have a Graphene Page Object.
@Location("/page")
public class MyPage {
@Drone
private WebDriver driver;
// page methods using the driver
}
And a Test Class that uses the page object.
@RunWith(Arquillian.class)
public class MyTest {
@Test
public void test(@InitialPage MyPage page) {
// use page & assert stuff
}
@Test
public void anotherTest(@InitialPage MyPage page) {
// use page & assert stuff even harder
}
}
Now, I've decided that MyTest should use method scoped Drone instances. So I add...
public class MyTest {
@Drone
@MethodLifecycle
private WebDriver driver;
Now when I run the test I get two browsers and all tests end with errors. Apparently this lifecycle management is treated as a qualifier too.
Yes, adding @MethodLifecycle in MyPage too helps. But this is not a solution - a page shouldn't care about this and should work in any WebDriver regardless of its scope. Only tests have the knowledge to manage the drone lifecycles. A page should just use whatever context it was invoked in. How can I achieve that?
This may be the answer:
But I'm afraid that this skips some Drone-specific enriching. Also not sure if it will correctly resolve when there are multiple Drone instances.