COR Lens · free Chrome extension
XPath finder Chrome extension
Click any element in Chrome and get a relative XPath, scored A to F. Copy the raw XPath, or the same locator for Selenium, Playwright or Cypress. No account, no setup.
<button id="submit-7f3a">Place order</button>//button[normalize-space()="Place order"]A 92//*[@id="checkout"]//buttonB 81//button[starts-with(@id, "submit-")]C 64
How it works
Three steps in Chrome
- 1
Add COR Lens to Chrome
Install it from the Chrome Web Store. There is nothing to sign up for and nothing to configure.
- 2
Click the element
Press Select Element and click the button, link or field you need. COR Lens lists every XPath it can build for it, best first.
- 3
Copy the XPath
Copy the raw XPath, or the same locator as
By.xpath,page.locatororcy.xpathfor your framework.
Relative XPath, never absolute
An absolute XPath such as /html/body/div[2]/main/div/form/button walks the page from the root. Add one wrapper div, and every test that used it breaks.
COR Lens only writes relative XPath, starting with //. It anchors on something the element owns: its id, its text, its attributes, or a stable neighbour.
What makes an XPath last
The XPaths that survive releases name what the element is: //button[normalize-space()="Place order"] or //input[@name="email"]. The ones that break describe where it happens to sit: (//div)[14], or a class name a build tool generated.
Every candidate COR Lens shows is scored A to F on uniqueness, stability and complexity, so you can see which XPath is the safe one before it reaches a test.
Axes, text and partial matches
When an element has nothing unique of its own, COR Lens reaches it from a stable neighbour with following-sibling or preceding-sibling, or matches its text with normalize-space() so stray whitespace does not matter.
Ids that change on every build get starts-with() on the part that stays the same, and two weak attributes can be combined with and into one strong match.
When XPath is not the best answer
If the element has a test id, a role with a name, or a label, a framework locator such as getByRole is shorter and survives redesigns better. COR Lens ranks XPath, CSS, test id and role candidates together, so you see when another kind wins.
Inside shadow DOM, XPath stops at the shadow root. COR Lens still generates locators there, with strategies that can cross it.
In your framework
The same locator, written for your tests
By.xpath("//button[normalize-space()=\"Place order\"]")page.locator('//button[normalize-space()="Place order"]')cy.xpath('//button[normalize-space()="Place order"]') // needs the cypress-xpath pluginIs the XPath finder free?
Yes. COR Lens is a free Chrome extension, with no account and no setup.
Does it give absolute or relative XPath?
Relative only. Every XPath starts with // and anchors on the element's id, text, attributes or a stable neighbour, never on the full path from /html.
Can I copy the XPath without framework code?
Yes. "Copy raw selector" copies the bare XPath. "Copy locator" copies it wrapped for your framework.
Does it work inside iframes and shadow DOM?
Yes. COR Lens has generation strategies for iframes, shadow DOM and tables, as well as Selenium relative locators.
Which test frameworks does it export to?
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.