COR Lens · free Chrome extension

CSS selector finder Chrome extension

Pick any element on a page and get its CSS selectors, each scored A to F for how likely it is to survive the next release. Copy one, or export it as test code.

Picked element<button data-testid="place-order" class="sc-bdVaJa kXyZqA">Place order</button>
  1. [data-testid="place-order"]A 95
  2. button[aria-label="Place order"]A 90
  3. .sc-bdVaJaF 22

How it works

Three steps in Chrome

  1. 1

    Install the extension

    COR Lens is on the Chrome Web Store. Once added, it works on any page you open.

  2. 2

    Select the element

    Choose Select Element, then click what your test needs to touch. The selectors appear ranked, strongest at the top.

  3. 3

    Copy the selector

    Take the bare CSS selector, or the framework version: By.cssSelector, page.locator or cy.get.

Why copied selectors break

The selector DevTools copies is built from position: #root > div:nth-child(3) > div > button. It finds the element today and a different one after the next layout change.

Class names are no safer when a build tool generated them. .sc-bdVaJa or .css-1q2w3e4 change on every release, so a selector built on them breaks without anyone touching the test.

What a stable CSS selector looks like

Stable selectors use attributes the team controls: [data-testid="place-order"], input[name="email"], button[aria-label="Close"]. They are short, and they say what the element is for.

COR Lens scores every selector A to F on uniqueness, stability and complexity. A generated class or a long nth-child chain scores low, so the fragile option is visible before you copy it.

CSS or XPath?

CSS is shorter and usually faster to read. It cannot select by visible text or step up to a parent, which XPath can.

COR Lens builds both for the same element and ranks them side by side, together with test id and role locators, so you can take whichever is strongest.

In your framework

The same locator, written for your tests

Seleniumdriver.findElement(By.cssSelector("[data-testid='place-order']"))
Playwrightpage.locator('[data-testid="place-order"]')
Cypresscy.get('[data-testid="place-order"]')

Questions

Questions

Can't find your answer? Ask in Discord or send us a message.

Does the CSS selector finder cost anything?

No. It is part of COR Lens, a free Chrome extension that needs no account.

How is this different from "Copy selector" in DevTools?

DevTools gives one selector built from the element's position. COR Lens builds several from its attributes, test ids and roles, and scores each one for stability.

Can it find elements inside iframes or shadow DOM?

Yes. It has strategies for iframes, shadow DOM and tables.

Can I export selectors to my framework?

Yes: Playwright, Cypress, Selenium, WebdriverIO, Nightwatch, TestCafe and Puppeteer.

Get your first graded locator

Free. No account. Works on any page you can open in Chrome.

Need an XPath instead? · Everything COR Lens does