8 Replies Latest reply on Sep 27, 2013 3:48 AM by Juraj Húska

    Graphen2 and @Page

    b69 Newbie

      After starting quick and dirty, ending with some green bars, I intend to go a step forward, using @Page to separate the html structure from the tests.

      Unfortunatly insted of getiing some text, I get:

      org.openqa.selenium.NoSuchElementException: Unable to locate element: {"method":"id","selector":"header"}!

      On breaking within the PageClass, and looking at the defined fields, all of them are marked with:

      com.sun.jdi.InvocationException occurred invoking method.

      Example of a WebElement declaration:

      @FindBy(id = "header")

          private WebElement headerText;


      digging a little bit deeper I see I have an import of:

      import org.jboss.arquillian.graphene.page.Page;

      while the Example in the Graphene2 documentation on Page Objects - Graphene 2 - Project Documentation Editor

      import org.jboss.arquillian.graphene.spi.annotations.Page;
      and extends the Class with extends AbstractGrapheneTest

        • 1. Re: Graphen2 and @Page
          Juraj Húska Master



          there is mistake in the documentation. Thanks for pointing that out.


          The correct package for @Page in Graphene 2.0.0.Beta1+ is, as you already said:


          You do not have to extend any class. Extending AbstractGrapheneTest in the documentation just wanted to note that all the other Arquillian related methods are higher in the hierarchy. I have to admit that it is quite misleading, and I will correct it.

          The com.sun.jdi.InvocationException is thrown by Eclipse debugger for me as well. We will look into that to improve it. It should not affect the functionality though. I have created this issue to address it:

          [#ARQGRA-380] Debugging in Eclipse throw InvocationException when inspecting fields enriched by Graphene - JBoss Issue T…

          Otherwise it should work as it is said in the guide:


          Have you resolved the issue somehow ? Are you sure that during runtime there is a element with id "header" ? Are you using JSF ? Is not it in the iframe ? Is the correct page loaded in your browser ?

          Thanks for the feedback anyway!

          1 of 1 people found this helpful
          • 2. Re: Graphen2 and @Page
            b69 Newbie

            Hi Jurai,

            Thanks. So w.r.t. Documentation it is clear now. For the rest, I resolved the issue. I simply overlooked the need to initialize the injected page explicitly with:

                  this.loginPage = PageFactory.initElements(this.browser, LoginPage.class);

            After this I get the expected values now from the page. So this issue is resolved.

            Right away I’m working on the next steps with new surprises on each step, but so far I could resolve them. .-)

            • 3. Re: Graphen2 and @Page
              Juraj Húska Master

              That is weird. You do not have to initialize Page Objects with any Page Factory. Graphene should take care of it. Could you please post the complete test code here ?

              • 4. Re: Graphen2 and @Page
                b69 Newbie

                I sent you a zip with three test classes as separated mail.

                • 5. Re: Graphen2 and @Page
                  b69 Newbie

                  Hi Juro,

                  Thanks for the hints.

                  I cleaned up my poms as you mentioned under 1). I prefer this solution which in fact is working!


                  ArquillianResource injection doesn't work, because I do not have any ShrinkWrap deployment. I started with it, but I found it very tedious to set it up. Maybe I must come back with it to make it fit into the test suite for the whole application. But actually I'm more interested to learn how to write the tests the best way and having the application deployed on the server makes it easier. Finalizing comes later.


                  What most will interest you, I do not need any page factoring anymore. It didn't work from the beginning, but fiddling around, restarting eclipse and cleaning directories in temp and on the server helped and finally it works as expected.


                  Meanwhile I set up the Firefox profile within the arquillian.xml too. This was foreseen anyway. The programed version was just a quick and dirty solution. However I wonder how to switch the preferred language of the browser on the fly. The application is multilingual, and it would be nice, if the language switch could be tested automatically too!

                  • 6. Re: Graphen2 and @Page
                    Juraj Húska Master

                    To Shrinkwrap:

                    I found useful deploying whole application in functional testing of the app. Here it is, how it can be achieved:


                    The only drawback currently with this approach is that it deploys the application for every test class, which can cause OutOfMemory proprlems. It will be solved in Arquillian 2, meanwhile easy workaround is to restart server after some tests classes...


                    Changing the language configuration on the fly:

                    I think that you can prepare multiple profiles for Firefox, where your desired language is set. Then you can use Graphene feature of multiple browsers instances described here:

                    Parallel browsers - Graphene 2 - Project Documentation Editor

                    You can configure each browser with custom firefox profile, and use them in one test. I hope I am clear here

                    1 of 1 people found this helpful
                    • 7. Re: Graphen2 and @Page
                      b69 Newbie

                      Hi Juraj,


                      Thanks for the hints. For multilanguage testing I suspected already, it must be done this way. I can live with that.

                      ShrinkWrap.createFromZipFile is a really good hint! Is it possible to create from a complete ear with actually 7 modules! I.e. 3 wars, one EJB-jar and 3 javaApp jars?

                      • 8. Re: Graphen2 and @Page
                        Juraj Húska Master

                        Afaik, it is possible. You can create one war and then add to it multiple archives with addArchive().