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.
<button data-testid="place-order" class="sc-bdVaJa kXyZqA">Place order</button>[data-testid="place-order"]A 95button[aria-label="Place order"]A 90.sc-bdVaJaF 22
How it works
Three steps in Chrome
- 1
Install the extension
COR Lens is on the Chrome Web Store. Once added, it works on any page you open.
- 2
Select the element
Choose Select Element, then click what your test needs to touch. The selectors appear ranked, strongest at the top.
- 3
Copy the selector
Take the bare CSS selector, or the framework version:
By.cssSelector,page.locatororcy.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
driver.findElement(By.cssSelector("[data-testid='place-order']"))page.locator('[data-testid="place-order"]')cy.get('[data-testid="place-order"]')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.