0 Replies Latest reply on Jan 21, 2015 11:27 PM by Vijay Pandey

    Arquillian Graphene - guardAjax - issue of - Request type 'XHR' was expected, but type 'HTTP' was done instead

    Vijay Pandey Newbie

      Using

      Arquillian - 1.1.5.Final

      Graphene - 2.1.0.Alpha1

      WildFly 8.1 Remote Container

      JEE 7 - JSF 2.2

       

      On a simple ajax request - guardAjax fails with the message "Request type 'XHR' was expected, but type 'HTTP' was done instead".

       

      But the ajax request gets executed and even the page gets updated with the ajax response, we are using reporter and screenshooter to verify the actual test, but somehow we still see this error.

       

      Here is the code snippet

      <h:form prependIds="false">
          <h:commandButton id="ajaxButtonId" value="HelloAjax" action="#{controllerBean.save}">
            <f:ajax render="panelId" />
         </h:commandButton>
         <h:panelGroup id="panelId">
            <h:panelGroup rendered="#{controllerBean.renderName}">
               <p>Your name is #{controllerBean.name}</p>
            </h:panelGroup>
         </h:panelGroup>
      </h:form>

       

         @Test

         @RunAsClient

         public void genericTest(){ 

          browser.get(deploymentUrl + "test.xhtml");

          Graphene.guardAjax(ajaxButton).click();

          System.out.println("Done testing:");

         }

       

      The problem appears in org.jboss.arquillian.graphene.guard.RequestGuardFactory in the method

       

      public <T> T guard(T target, final RequestType requestExpected, final boolean strict) {

       

      ------

      @Override

                  public Object intercept(InvocationContext context) throws Throwable {

       

       

                      guard.clearRequestDone();

       

       

                      Object result = context.invoke();

       

       

                      RequestType requestType;

       

       

                      if (strict) {

                          requestType = waitForRequestChange();

                      } else {

                          requestType = waitForRequestType(requestExpected);

                      }

       

       

                      if (requestType.equals(requestExpected)) {

                          waitForRequestFinished();

                      } else {

                          throw new RequestGuardException(requestExpected, requestType);

                      }

       

       

                      return result;

                  }

      ------------------------------------------------------------------

       

      In the above method after ajax request (context.invoke()) is invoked (action method of jsf), the value returned from the method "waitForRequestChange" - as marked in red above returns value as "HTTP" instead of "XHR" - not sure why

       

      The exception stacktrace is

       

      org.jboss.arquillian.graphene.request.RequestGuardException: Request type 'XHR' was expected, but type 'HTTP' was done instead

        at org.jboss.arquillian.graphene.guard.RequestGuardFactory$1.intercept(RequestGuardFactory.java:110)

        at org.jboss.arquillian.graphene.proxy.InvocationContextImpl.invoke(InvocationContextImpl.java:87)

        at org.jboss.arquillian.graphene.proxy.GrapheneContextualHandler$2.call(GrapheneContextualHandler.java:213)

        at org.jboss.arquillian.graphene.context.BrowserActions.performAction(BrowserActions.java:62)

        at org.jboss.arquillian.graphene.proxy.GrapheneContextualHandler.invoke(GrapheneContextualHandler.java:209)

        at org.jboss.arquillian.graphene.proxy.GrapheneContextualHandler.intercept(GrapheneContextualHandler.java:233)

        at org.openqa.selenium.remote.RemoteWebElement$$EnhancerByGraphene$$5937839e.click(<generated>)

        at arquilliantest.test.AjaxTest.genericTest(AjaxTest.java:55)

        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)

        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)

        at java.lang.reflect.Method.invoke(Method.java:601)

        at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:47)

        at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)

        at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:44)

        at org.jboss.arquillian.junit.Arquillian$6$1.invoke(Arquillian.java:301)

        at org.jboss.arquillian.container.test.impl.execution.LocalTestExecuter.execute(LocalTestExecuter.java:60)

        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)

        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)

        at java.lang.reflect.Method.invoke(Method.java:601)

        at org.jboss.arquillian.core.impl.ObserverImpl.invoke(ObserverImpl.java:94)

        at org.jboss.arquillian.core.impl.EventContextImpl.invokeObservers(EventContextImpl.java:99)

        at org.jboss.arquillian.core.impl.EventContextImpl.proceed(EventContextImpl.java:81)

        at org.jboss.arquillian.core.impl.ManagerImpl.fire(ManagerImpl.java:145)

        at org.jboss.arquillian.core.impl.ManagerImpl.fire(ManagerImpl.java:116)

        at org.jboss.arquillian.core.impl.EventImpl.fire(EventImpl.java:67)

        at org.jboss.arquillian.container.test.impl.execution.ClientTestExecuter.execute(ClientTestExecuter.java:53)

        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)

        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)

        at java.lang.reflect.Method.invoke(Method.java:601)

        at org.jboss.arquillian.core.impl.ObserverImpl.invoke(ObserverImpl.java:94)

        at org.jboss.arquillian.core.impl.EventContextImpl.invokeObservers(EventContextImpl.java:99)

        at org.jboss.arquillian.core.impl.EventContextImpl.proceed(EventContextImpl.java:81)

        at org.jboss.arquillian.container.test.impl.client.ContainerEventController.createContext(ContainerEventController.java:142)

        at org.jboss.arquillian.container.test.impl.client.ContainerEventController.createTestContext(ContainerEventController.java:129)

        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)

        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)

        at java.lang.reflect.Method.invoke(Method.java:601)

        at org.jboss.arquillian.core.impl.ObserverImpl.invoke(ObserverImpl.java:94)

        at org.jboss.arquillian.core.impl.EventContextImpl.proceed(EventContextImpl.java:88)

        at org.jboss.arquillian.test.impl.TestContextHandler.createClassContext(TestContextHandler.java:84)

        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)

        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)

        at java.lang.reflect.Method.invoke(Method.java:601)

        at org.jboss.arquillian.core.impl.ObserverImpl.invoke(ObserverImpl.java:94)

        at org.jboss.arquillian.core.impl.EventContextImpl.proceed(EventContextImpl.java:88)

        at org.jboss.arquillian.test.impl.TestContextHandler.createTestContext(TestContextHandler.java:102)

        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)

        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)

        at java.lang.reflect.Method.invoke(Method.java:601)

        at org.jboss.arquillian.core.impl.ObserverImpl.invoke(ObserverImpl.java:94)

        at org.jboss.arquillian.core.impl.EventContextImpl.proceed(EventContextImpl.java:88)

        at org.jboss.arquillian.test.impl.TestContextHandler.createSuiteContext(TestContextHandler.java:65)

        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)

        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)

        at java.lang.reflect.Method.invoke(Method.java:601)

        at org.jboss.arquillian.core.impl.ObserverImpl.invoke(ObserverImpl.java:94)

        at org.jboss.arquillian.core.impl.EventContextImpl.proceed(EventContextImpl.java:88)

        at org.jboss.arquillian.core.impl.ManagerImpl.fire(ManagerImpl.java:145)

        at org.jboss.arquillian.test.impl.EventTestRunnerAdaptor.test(EventTestRunnerAdaptor.java:111)

        at org.jboss.arquillian.junit.Arquillian$6.evaluate(Arquillian.java:294)

        at org.jboss.arquillian.junit.Arquillian$5.evaluate(Arquillian.java:267)

        at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:271)

        at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:70)

        at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:50)

        at org.junit.runners.ParentRunner$3.run(ParentRunner.java:238)

        at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:63)

        at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:236)

        at org.junit.runners.ParentRunner.access$000(ParentRunner.java:53)

        at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:229)

        at org.jboss.arquillian.junit.Arquillian$2.evaluate(Arquillian.java:193)

        at org.jboss.arquillian.junit.Arquillian.multiExecute(Arquillian.java:345)

        at org.jboss.arquillian.junit.Arquillian.access$200(Arquillian.java:49)

        at org.jboss.arquillian.junit.Arquillian$3.evaluate(Arquillian.java:207)

        at org.junit.runners.ParentRunner.run(ParentRunner.java:309)

        at org.jboss.arquillian.junit.Arquillian.run(Arquillian.java:155)

        at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:50)

        at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)

        at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:459)

        at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:675)

        at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:382)

        at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:192)