webdriverio / chrome-recorder

Generate WebdriverIO Tests from Google Chrome DevTools Recordings.
https://webdriver.io
MIT License
34 stars 6 forks source link

Add support for text and XPath selector #3

Closed jecfish closed 1 year ago

jecfish commented 2 years ago

DevTools Recorder support text and XPath selector from Chrome 108 onwards. I am wondering if there are similar selector in WebdriverIO?

Here is the example step's json.

{
      "type": "click",
      "target": "main",
      "selectors": [
        [
          "aria/Proceed to checkout"
        ],
        [
          "[data-test=checkout]"
        ],
        [
          "xpath///*[@data-test=\"checkout\"]"
        ],
        [
          "text/Total: $0.00"
        ]
      ]
    }
Screen Shot 2022-10-16 at 9 35 19 AM
christian-bromann commented 2 years ago

Oh awesome.

Right now WebdriverIO prefers aria selectors aria/... and creates an xPath from it based on the conditions described in the w3c protocol. We could change the current implementation to prefer the xPath if given by Chrome.

christian-bromann commented 1 year ago

Implemented that xPath is preferred selector after id and before aria label, given that aria labels are IMO less deterministic than xPaths. Thanks for filing the issue.