Skip to content

New strategy:value syntax to specify locator strategy in addition to current strategy=value #908

Closed

Description

@pekkaklarck

Currently when specifying a non-default locator for an element, the syntax is name=value like in xpath=//h1 or css=h1. This works well otherwise, but the same syntax is also used by Robot Framework's named argument syntax and this can cause confusion.

Using the same syntax also causes actual problems if a keyword would accept **kwargs, because then Robot considers all arguments looking like name=value to match it. There's also a possibility that some time in the future Robot will always do that, regardless on the function signature. Robot allows escaping the problematic = like in name\=value (e.g. css\=h1) but that is a bit ugly if needed often.

My proposal is that in addition to the existing =, we allow using : like name:value (or name: value or even name : value as we allow spaces to used with = too). The reason I propose : is that it's visually quite close to =, it's used by Robot on the command like (e.g. -v name:value), and it's also used by Python in similarly as = in some contexts (e.g.{'name': 'value'} and dict(name=value)). We don't need to deprecate the current syntax at least now, but documentation should be written so that the new syntax is recommended.

This change causes backwards incompatibility problems if someone has used a default locator (e.g. id) which has : in its value like Click Element foo:bar. We don't expect : to be too common in locator values, and there's always a possibility to use id:foo:bar or id=foo:bar to avoid the problem. If there are lot of complaints during the SL 3.0 release candidate phase, we can still consider ways to make the transition smoother.

Activity

  1. added this to the v3.0.0 milestone on Sep 18, 2017
  2. changed the title [-]New syntax to specify locator type in addition to current `type=value`[/-] [+]New `type:value` syntax to specify locator type in addition to current `type=value`[/+] on Sep 19, 2017
  3. added a commit that references this issue on Sep 21, 2017
  4. changed the title [-]New `type:value` syntax to specify locator type in addition to current `type=value`[/-] [+]New `strategy:value` syntax to specify locator strategy in addition to current `strategy=value`[/+] on Sep 25, 2017
  5. added a commit that references this issue on Sep 25, 2017
  6. pekkaklarck commented on Sep 26, 2017

    @pekkaklarck
    MemberAuthor

    This issue is now otherwise done, but table related keywords still support only the strategy=value syntax. This is due to table keywords having their own locator logic. That's a bad idea in general and #923 aims to fix it.

  7. aaltat commented on Sep 26, 2017

    @aaltat
    Contributor

    After the #923 is merged the #926 updates the documentation.

  8. pekkaklarck commented on Sep 27, 2017

    @pekkaklarck
    MemberAuthor

    PR #923 fixed inconsistencies with table locators and #926 updated related docs. This issue can be considered done.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions