3 Replies Latest reply on Mar 24, 2011 5:57 AM by Lukáš Fryč

    Selenium - unconditioned A4J-WAIT

    Oliver G. Newbie




      I considered the RichFaces-Selenium library (http://community.jboss.org/wiki/RichFaces-SeleniumLibrary) and took a look at the a4j-wait possibilities. They seem to be based on passing change conditions.


      For our test cases here, it seems very comfortable to have a unconditioned a4j-wait function. I found this http://blogs.nuxeo.com/dev/2009/03/selenium-ajax-requests.html . It makes use of the selenium user-extensions and registers a listener via A4J.AJAX.AddListener().


      Using this I could decrease the selenium execution time to about 200 ms (works for ca. 95% of our test cases). A lower value is not possible, I think because the time the browser needs for rerendering is still not considered.


      My question: Is there a client-side possibility in RF to get the moment, when a rerender phase is completed (e.g. after a4j:support reRender=...) which could be used in the user-extensions? (Note: I'm not in a JSF context with the selenium tests) I mean something like the above A4J.AJAX.AddListener(), but for rerendering. Richfaces.AddRenderListener() or Richfaces.AllRerenderCompleted would be nice


      Thank you very much!

        • 1. Selenium - unconditioned A4J-WAIT
          Lukáš Fryč Master

          Hi Oliver,


          I encourage you to use richfaces-selenium library (the API is moreless compatible to newly started project Arquillian Ajocado, so it will help you migrate to this new cool framework in future ;-)


          Look for RequestTypeGuard in documentation link you have posted [1], I think it is what you are looking for.


          [1] http://community.jboss.org/wiki/RichFaces-SeleniumLibrary


          RequestTypeGuard intercepts each XMLHttpRequest and waits for it's completion - it means it waits for end of COMPLETED phase of XHR request in which is rendering done - the solution was developed for testing of RichFaces itself. ;-)

          • 2. Selenium - unconditioned A4J-WAIT
            Oliver G. Newbie

            Hi Lukas,


            thanks a lot!


            I will check, if I can let inherit the super class for our Selenium-Tests from AbstractTestCase of richfaces-selenium after refactoring a bit.


            BTW: I looked at initializeBrowser() with the @BeforeClass-Annotation in AbstractTestCase and saw that the selenium instance will be initialized every time there. What do you think is the best way, if I want a single initialization (+ login) for all my test classes (maybe in a test-suite) -- Overwrite initializeBrowser() in own super class for the tests (which holds e.g. something like a initialized-flag)?

            • 3. Selenium - unconditioned A4J-WAIT
              Lukáš Fryč Master

              Hi Oliver,


              I discourage you to use single initialization point (like login before suite) - it makes tests to be not separated and fragile.


              Say your test will make user session to fail and login user will not be able to reuse session that is already started.

              It makes the rest of test suite to fail.


              But if you will use the session-per-class principle as it is now, only one test class will fail.

              1 of 1 people found this helpful