0 Replies Latest reply on Feb 28, 2019 5:09 PM by dozer247

    java.lang.IllegalStateException when using @MethodLifecycle

    dozer247

      Hi,

       

      We are using junit and running multiple test in the the same class.  Our tests are passing but we are getting an overall java.lang.IllegalStateException: There is no context available for qualifier org.jboss.arquillian.drone.api.annotation.Default. Available contexts are [].

      We are using @MethodLifecycle because we want a new browser instance for each test.

       

      The full stack track is below

       

      java.lang.IllegalStateException: There is no context available for qualifier org.jboss.arquillian.drone.api.annotation.Default. Available contexts are [].
      at org.jboss.arquillian.graphene.context.GrapheneContextImpl$LazyContext.getContext(GrapheneContextImpl.java:302)
      at org.jboss.arquillian.graphene.context.GrapheneContextImpl$LazyContext$1.getTarget(GrapheneContextImpl.java:311)
      at org.jboss.arquillian.graphene.proxy.GrapheneProxyHandler.getTarget(GrapheneProxyHandler.java:147)
      at org.jboss.arquillian.graphene.proxy.GrapheneContextualHandler.invoke(GrapheneContextualHandler.java:124)
      at org.jboss.arquillian.graphene.proxy.GrapheneContextualHandler.intercept(GrapheneContextualHandler.java:263)
      at org.openqa.selenium.chrome.ChromeDriver$$EnhancerByGraphene$$fc4daea9.unwrap()
      at org.jboss.arquillian.graphene.integration.GrapheneEnhancer.deenhance(GrapheneEnhancer.java:73)
      at org.jboss.arquillian.graphene.integration.GrapheneEnhancer.deenhance(GrapheneEnhancer.java:42)
      at org.jboss.arquillian.drone.impl.DroneEnhancer.deenhanceDrone(DroneEnhancer.java:129)
      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
      at java.lang.reflect.Method.invoke(Method.java:498)
      at org.jboss.arquillian.core.impl.ObserverImpl.invoke(ObserverImpl.java:86)
      at org.jboss.arquillian.core.impl.EventContextImpl.invokeObservers(EventContextImpl.java:103)
      at org.jboss.arquillian.core.impl.EventContextImpl.proceed(EventContextImpl.java:90)
      at org.jboss.arquillian.core.impl.ManagerImpl.fire(ManagerImpl.java:133)
      at org.jboss.arquillian.core.impl.ManagerImpl.fire(ManagerImpl.java:105)
      at org.jboss.arquillian.core.impl.EventImpl.fire(EventImpl.java:62)
      at org.jboss.arquillian.drone.impl.DroneDestructor.destroyDrone(DroneDestructor.java:82)
      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
      at java.lang.reflect.Method.invoke(Method.java:498)
      at org.jboss.arquillian.core.impl.ObserverImpl.invoke(ObserverImpl.java:86)
      at org.jboss.arquillian.core.impl.EventContextImpl.invokeObservers(EventContextImpl.java:103)
      at org.jboss.arquillian.core.impl.EventContextImpl.proceed(EventContextImpl.java:90)
      at org.jboss.arquillian.core.impl.ManagerImpl.fire(ManagerImpl.java:133)
      at org.jboss.arquillian.core.impl.ManagerImpl.fire(ManagerImpl.java:105)
      at org.jboss.arquillian.core.impl.EventImpl.fire(EventImpl.java:62)
      at org.jboss.arquillian.drone.impl.DroneLifecycleManager.afterClass(DroneLifecycleManager.java:213)
      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
      at java.lang.reflect.Method.invoke(Method.java:498)
      at org.jboss.arquillian.core.impl.ObserverImpl.invoke(ObserverImpl.java:86)
      at org.jboss.arquillian.core.impl.EventContextImpl.invokeObservers(EventContextImpl.java:103)
      at org.jboss.arquillian.core.impl.EventContextImpl.proceed(EventContextImpl.java:90)
      at org.jboss.arquillian.test.impl.TestContextHandler.createClassContext(TestContextHandler.java:83)
      at sun.reflect.GeneratedMethodAccessor107.invoke(Unknown Source)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
      at java.lang.reflect.Method.invoke(Method.java:498)
      at org.jboss.arquillian.core.impl.ObserverImpl.invoke(ObserverImpl.java:86)
      at org.jboss.arquillian.core.impl.EventContextImpl.proceed(EventContextImpl.java:95)
      at org.jboss.arquillian.test.impl.TestContextHandler.createSuiteContext(TestContextHandler.java:69)
      at sun.reflect.GeneratedMethodAccessor106.invoke(Unknown Source)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
      at java.lang.reflect.Method.invoke(Method.java:498)
      at org.jboss.arquillian.core.impl.ObserverImpl.invoke(ObserverImpl.java:86)
      at org.jboss.arquillian.core.impl.EventContextImpl.proceed(EventContextImpl.java:95)
      at org.jboss.arquillian.core.impl.ManagerImpl.fire(ManagerImpl.java:133)
      at org.jboss.arquillian.core.impl.ManagerImpl.fire(ManagerImpl.java:105)
      at org.jboss.arquillian.test.impl.EventTestRunnerAdaptor.afterClass(EventTestRunnerAdaptor.java:95)
      at org.jboss.arquillian.junit.Arquillian$3$1.evaluate(Arquillian.java:183)
      at org.jboss.arquillian.junit.Arquillian.multiExecute(Arquillian.java:350)
      at org.jboss.arquillian.junit.Arquillian.access$200(Arquillian.java:54)
      at org.jboss.arquillian.junit.Arquillian$3.evaluate(Arquillian.java:177)
      at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
      at org.jboss.arquillian.junit.Arquillian.run(Arquillian.java:115)
      at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:89)
      at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:41)
      at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:541)
      at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:763)
      at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:463)
      at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:209)

       

       

      are junit test class basically looks like the following

       

      public class SeleniumTest {
       
        @ArquillianResource
        public URL baseUrl;
      
        @Drone
        @MethodLifecycle
        public WebDriver driver;
      
        @Page
        protected LoginPage loginPage;
       
        @Before
        public void init() {
        String propertyFile = "test.properties";
        if (System.getProperty("1place.env") != null) {
        String env = System.getProperty("1place.env");
        propertyFile = env + ".properties";
        }
      
        InputStream is = getClass().getResourceAsStream("/" + propertyFile);
        Properties props = new Properties();
      
        try {
        props.load(is);
        } catch (IOException e) {
        e.printStackTrace();
        throw new RuntimeException("missing properties file");
        }
      
        }
      
        @Page
        protected HomeIndex homeIndex;
      
        @After
        public void destroy() {
       
        }
       
        @Test
        public void testOne() throws Exception {
       
       
        }
       
        @Test
        public void testTwo() throws Exception {
       
       
        }
       
        @Test
        public void testThree() throws Exception {
       
       
        }
      
      }

       

       

      Does anyone have any ideas whats causing the Exception?

       

      Regards