4 Replies Latest reply on Apr 14, 2010 2:41 AM by mettehummel

    Selenium tests and click in extendedDataTable

    mettehummel

      Hi

       

      I'm trying to set up some Selenium tests towards an applikation where we use RichFaces 3.3.3 CR1. I'm running into problems when I try to click on one of the rows in an extended data table. The Selenium target for clicking on the first row looks like this:

       

      hovedForm:gldKodeTabell:no.skd.sl.domain.GldKodeBeskrivelse@f99f26:test

       

      If I just rerun the test it works fine. The problem is that when I try to run the test later after I have restarted the application server I get this message:

       

      [error] Element hovedForm:gldKodeTabell:no.skd.sl.domain.GldKodeBeskrivelse@f99f26:test not found

       

      and it turns out that the line have this id: hovedForm:gldKodeTabell:no.skd.sl.domain.GldKodeBeskrivelse@506d2d:test

       

      What do I need to do in order to be get reproducable ids for the rows in an extendedDataTabel?

       

       

                      <rich:extendedDataTable value="#{ltoKodeBean.gldDataModel}"

                              var="linje" id="gldKodeTabell" height="350px"

                              sortMode="single"

                              selectionMode="multi"

                              selection="#{ltoKodeBean.selection}"

                              selectedClass="valgtRadStyle"

                              noDataLabel="#{tekster.ingenResultater}"

                              enableContextMenu="false">

        • 1. Re: Selenium tests and click in extendedDataTable
          nbelaevski

          Hi Mette,

           

          Iteration components use "rowKey" property of the ExtendedDataModel to create clientId for the iterated components. I can guess that in your case no.skd.sl.domain.GldKodeBeskrivelse@f99f26 is rowKey.toString() of the custom model key. So, you can use simpler keys (e.g. Integer) or define "rowKeyConverter" that will handle keys.

          • 2. Re: Selenium tests and click in extendedDataTable
            mettehummel

            Thanks, but how do I set up a rowKeyConverter?

            • 3. Re: Selenium tests and click in extendedDataTable
              lfryc

              Hello Mette,

               

              from your sample it seems that you are addressing problem with changing IDs of elements, because the ID is generated by toString() method. This method generates unique object instance representation, however this ID will be changed between another instances of JVM.

               

              You have two options here:

               

              1. you can find another way how to address the element without need for specific ID, for example by using XPath:

               

              sample: http://livedemo.exadel.com/richfaces-demo/richfaces/extendedDataTable.jsf

               

              example xpathes for "Arkansas" row:

               

              //div[contains(@class,'extdt-content')]/table/tbody/tr[4]


              //div[contains(@class,'extdt-content')]/table/tbody/tr[td[2]/div/text()='Arkansas']

               

               

               

              2. you can change underlying application, for example as suggested Nick you can use rowKeyConverter, from documentation:

               

              <rich:extendedDataTable ... rowKeyConverter="#{myConverter}" />

               

              where myConverter must evaluate to javax.faces.convert.Converter

               

              This converter must to convert given row key (from data model) to unique string representation and vice-versa.

              • 4. Re: Selenium tests and click in extendedDataTable
                mettehummel

                Thanks!

                 

                The xpath suggestion worked fine. I added the following Selenium test which made Selenium click on the third column of the first row:     

                 

                clickAt               xpath=id('hovedForm:gldKodeTabell:n:0')/x:td[3]/x:div/x:input/