2 Replies Latest reply on Jul 24, 2012 9:31 AM by jbosscommunity13

    Integration Tests Richfaces 4 AJAX and e.g. Selenium (Requirement)

    jbosscommunity13 Newbie

      Hello Richfaces Community,

       

      I have a requirement and in case there is already an implemented solution, a question.

       

      "How can I hook into tha a4j cycle on the client side (browser) in a generic way to know if there is an active ajax call pending?"

       

      We do a lot of browser integration testing with Selenium. Those who know selenium know that when you run the scripts in a certain speed you do get problems with ajax Calls,

      because you can not always detect them for sure. (Waiting for an element present is also not always a solution, because after certain ajax calls no change might happen too!)

       

      So I studied the internet for solutions, some seem to be very promising.

       

      Hidden Field Solution

      Like:

      <h:inputHidden id="ajaxRequestStatus" value="AJAX_REQUEST_INACTIVE"/>

       

      on every ajax component a jsFunctionCall to change the value in the hidden field

      [...]

      <a4j:ajax event="change" onbeforesubmit="setHiddenAjaxFieldActive()" oncomplete="setHiddenAjaxFieldInactive()" ...

      [...]

       

      like this, in Selenium you can now use the command "waitForCondition" which loops as long as a javaScriptFunction becomes true (e.g. the hidden field has the value "AJAX_REQUEST_INACTIVE") or of course when it reaches the given timeout.

       

      That solution works 100%, but it requires that all (every single) ajax component need to implement this 2 methods....

       

      In Selenium many User try to get over the browserbot to find out if there is an active ajax Call

      selenium.browserbot.getCurrentWindow().jQuery.active == 0

       

      This doenst work very reliable unfortunately!

       

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

      So my question:

      Is there a solution for this requirement?

       

      The Richfaces Ajax-Status Component e.g. is a Component that is already aware of when the cycle is over... so the information must be known

      by an the clientside Object. The ajax Queue Object ist also not usabel for it, because it doens hold the information if one element left the queue is already worked off...

       

      it would be nice to have access something like in this Fashion:

      RichFaces.getNumberOfActiveAjaxCalls()

       

      I tried to find out in runtime if any of the accesible methods in the RichFaces Js Object could be helpful but I couldn't locate any.

       

      Is this a candidate for future releases, to make the number of acrtive ajax calls accesible through the RichFaces Object?

      Could it Integrate with JSF 2 Ajax calls?

       

      It would be a very helpful benefit for testability of web applications.

      For any hints, suggestions and comments, very apreciated!

       

      RichFaces

      Object { RICH_CONTAINER="rf", KEYS={...}, log={...}, mehr...}

      Event

      Object { RICH_NAMESPACE="RICH", EVENT_NAMESPACE_SEPARATOR=".", MESSAGE_EVENT_TYPE="onmessage"}

      KEYS

      Object { BACKSPACE=8, TAB=9, RETURN=13, mehr...}

      Push

      Object { transport="long-polling", increaseSubscriptionCounters=function(), decreaseSubscriptionCounters=function(), mehr...}

      RICH_CONTAINER

      "rf"

      Selection

      Object { set=function(), getStart=function(), getEnd=function(), mehr...}

      ajaxContainer

      Object { jsfRequest=request(), jsfResponse=response(), isIgnoreResponse=function()}

      isIgnoreResponse

      function()

      jsfRequest

      request(source, event, options)

      jsfResponse

      response(request, context)

      calendarTemplates

      Object { evalMacro=function()}

      calendarUtils

      Object { joinArray=function(), getMonthByLabel=function(), createDate=function(), mehr...}

      csv

      Object { RE_DIGITS=RegExp, RE_FLOAT=RegExp, addMessage=function(), mehr...}

      jQuery

      Object { createFunction=function(), query=function()}

      createFunction

      function()

      query

      function()

      log

      Object { debug=function(), info=function(), warn=function(), mehr...}

      queue

      Object { DEFAULT_QUEUE_ID="org.richfaces.queue.global", getSize=function(), isEmpty=function(), mehr...}

      statusName

      "suchStatus"

      ui

      Object { ComponentControl={...}, MenuKeyNavigation={...}, TooltipMode={...}, mehr...}

      utils

      Object { addCSSText=function(), getCSSRule=function(), Ranges=function(), mehr...}

      BaseComponent

      function()

      BaseNonVisualComponent

      function()

      HtmlLog

      function()

      blankFunction

      function()

      $

      function()

      $$

      function()

      ajax

      function()

      cleanComponent

      function()

      cleanDom

      function()

      clonePosition

      function()

      createJSFEventsAdapter

      function()

      escapeCSSMetachars

      function()

      evalMacro

      function()

      findNonVisualComponents

      function()

      getDomElement

      function()

      getValue

      function()

      interpolate

      function()

      invokeMethod

      function()

      parseJSON

      function()

      setGlobalStatusNameVariable

      function()

      setLog

      function()

      setZeroRequestDelay

      function()

      submitForm

      function()