testing-library / testing-library-recorder-extension

Testing Library Extension for Chrome DevTools Recorder
https://chrome.google.com/webstore/detail/testing-library-recorder/pnobfbfcnoeealajjgnpeodbkkhgiici?utm_source=github&utm_medium=referral
MIT License
144 stars 3 forks source link

Add support for text and xpath selectors #27

Open jecfish opened 1 year ago

jecfish commented 1 year ago

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

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
nickmccurdy commented 1 year ago

This recorder extension is designed to work with Jest and Vitest (soon), so we assume something like JSDOM is implementing DOM APIs. We could use document.evaluate to implement getElementByXpath, as long as the DOM implementation supports this. Otherwise, we could run tests directly in a real browser with something like Karma, Puppeteer, or Playwright.