1 Reply Latest reply on Sep 29, 2010 5:13 AM by nadya.staneva

    how to wait a combo rerender after loading data using ajax request Selenium test

    nadya.staneva

      Hi,

      I have a problem testing a page with Selenium RC. I'm using RichFaces and I have a combo box for brand of car and another for chosing the model of the car, so the model depends on the brand and it rerenders after choosing the brand:

       

              <dx:inputCombo id="mps_model" required="true" value="#{policySelector.data.mps.model}"
                  label="#{msg.policies_mps_data_model}" selectItems="#{models}"
                  showEmptyElement="true" emptyElementLabel="#{msg.global_choose}"
                  disabled="#{policySelector.data.isFinished}">
                 
                  <a4j:support event="onchange" action="selectBrand"
                      reRender="#{flowRenderFragments}" ajaxSingle="true"/>   
              </dx:inputCombo>

       

      So I have a combo box that loads data using ajax request and I need to select a value from the combo after it has loaded in order to test it with Selenium. I followed this article: http://blogs.nuxeo.com/dev/2009/03/selenium-ajax-requests.html and now it waits until the request has finished and then tries to select the value.

       

      The problem is that after the request has finished, the combo is not ready yet because it adds the options one by one and it takes additional time and Selenium clicks too fast . So the Selenium test fails because it tries to select an option which has not been loaded in the combo yet.

      Can you please tell me how to make it wait until the combo stops loading?

        • 1. Re: how to wait a combo rerender after loading data using ajax request Selenium test
          nadya.staneva

          I have found a solution but I don't think it's the best idea:

          Before we select the brand of the car in the first combo we add dynamically an attribute to the second combo(for the model) showing that it is not rerendered yet. Then we select the brand of the car and wait (for the ajax requests to finish) with the funcitons shown in this article: http://blogs.nuxeo.com/dev/2009/03/selenium-ajax-requests.html .Next we wait until we are sure that the attribute in the combo is not there (thus the combo is already rerendered) and the we are sure that the combo has loaded all its options and we can select the model of the car.


          If anyone has a better solution that is more general and not using things like adding an attribute and then checking if it is there, please tell me.