rod icon indicating copy to clipboard operation
rod copied to clipboard

Add support to get the css path or xpath of an element

Open hhhapz opened this issue 4 years ago • 1 comments

Is your feature request related to a problem? Please describe. Can be useful when debugging during runs.

Describe the solution you'd like Implementation from the CDT Frontend project: https://github.com/ChromeDevTools/devtools-frontend https://discordapp.com/channels/719933559456006165/721227572805107785/727145462242476116

hhhapz avatar Jun 29 '20 13:06 hhhapz

The exact file to check is https://github.com/ChromeDevTools/devtools-frontend/blob/master/front_end/elements/DOMPath.js

We can traverse from the leaf to the root of the dom tree and build the path. Not only XPath, but also CSS selector.

We should also design an algorithm to search for the shortest selector, resilient selector.

Ref: https://github.com/microsoft/playwright/blob/da1dafcadb05fd648f13610d8eefc4baa5c2261e/src/server/supplements/injected/selectorGenerator.ts

ysmood avatar Jul 03 '20 07:07 ysmood