4 Replies Latest reply on Sep 3, 2013 2:30 AM by Juraj Húska

    Graphene: proposal of API change of FindBy to achieve extensibility

    Lukáš Fryč Master

      We currently use @FindBy annotation as a replacement for WebDriver's own @FindBy annotation.


      Those annotation allows to specify what location strategy to use, supporting variety of strategies from element identifiers, CSS selectors, XPath to some other bizzare ways.



      The purpose of own @FindBy annotation was to extend this set of location strategies by support for jQuery.




      The FindBy allows to specify element location in following ways:


      @FindBy(id = 'xyz')

      @FindBy(css = '.class')

      @FindBy(jquery = '.class:visible')




      @FindBy(how = CSS, using = '.class')




      However neither from those styles allows for extensibility.


      We can't introduce new properties to @FindBy(my_strategy=...) nor we can extend How with MY_STRATEGY because it's enum.




      The number of use cases where extending the location strategy would be useful are plethora, but most prominent is particular need of some web frameworks:





      Location by JSF IDs


      the server_id is a short version of long clientId, which can differ by the environment in which the component is used


      Location by AngularJS Model names


      AngularJS comes with its own expression language where expressions can be used in HTML markup.

      We could use model names to find elements on the page which is a similar what End-to-End tests for AngularJS use.



      Question is simple: how to allow for extensibility of FindBy?