Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
Clear All
new posts

    Selenium Webdriver: scLocator fallback strategies don't work

    As I've understood the vast amount of property checks in scLocators is built so changes to the source code don't destroy test cases.

    I'm trying to write Selenium tests in WebDriver with the nightly SmartGWT 6.1d build from Sunday.

    The following selector is generated during the test:
    driver.clicks(ByScLocator.scLocator("//ListGrid[ID='FeverchartSearchIncludingAlternativesResultGrid']/body/row[medname=Marcoumar%20Tbl%203mg||1]"));

    When the medname is something different than "Marcoumar..." the command fails with an ElementNotFound exception.

    I've tested several selectors and found the following behaviour:
    Command Result
    driver.findElements(ByScLocator.scLocator("//ListGrid[ID='FeverchartSearchIncludingAlternativesResultGrid']/body/row[medname=Marcoumar%20Tbl%203mg||1]")).size() 1
    driver.findElements(ByScLocator.scLocator("//ListGrid[ID='FeverchartSearchIncludingAlternativesResultGrid']/body/row")).size() 0
    driver.findElements(ByScLocator.scLocator("//ListGrid[ID='FeverchartSearchIncludingAlternativesResultGrid']/body/row[1]")).size() 1
    driver.findElements(ByScLocator.scLocator("//ListGrid[ID='FeverchartSearchIncludingAlternativesResultGrid']/body/row[medname=foo||1")).size() 0
    driver.findElements(ByScLocator.scLocator("//ListGrid[ID='FeverchartSearchIncludingAlternativesResultGrid']/body/row[medname111=foo||1")).size() 0
    So as soon as the first property check in the square brackets fail it does not continue with the other property checks.

    Our application is running on SmartGWT 4.1 with the build from 26th November 2015.

    Edit: Even with the lastest version built on 3rd June 2016 the fallback methods have no effect.

    One more thing I want to mention is that locators where multiple elements could be returned only return 1. findElements always returns either 0 or 1 elements, depending on whether an element has been found with the locator.
    Last edited by stefan_berger; 7 Jun 2016, 05:56.

    #2
    Bump

    Comment


      #3
      See ListGrid.locateRowsBy: multiple ways of locating records are available in the ListGrid, but only one is actually used by the ListGrid, based on locateRowsBy.

      We don't know of a use case for actually falling back to index-based lookups after a property-based lookup has failed - that would seem to be basically a recipe for false positives.

      About findElements - yes, all locators are designed to return at most a single element.

      Comment


        #4
        So when do fallback strategies work and when not?

        Comment


          #5
          They work whenever there isn't documentation explaining that the "fallback" parts of the locator serve a different purpose.

          Comment


            #6
            Sorry but I can't find any documentation on fallback strategies. Could you please advise me where I need to look?

            Comment


              #7
              See ListGrid.locateRowsBy() and ListGrid.locateColumnsBy().

              Comment

              Working...
              X