gtoffoli
gtoffoli

Reputation: 86

React to interactive element selection in Chrome DevTools

With Chrome DevTools, by enabling "select an element in the page to inspect it", it is possible to highlight and select an element in the content window and to get information on it in the Elements panel of the Inspector.

I would like to extend the "element selected" event handler for sending to a server the page url and the xpath of the selected element. Any suggestion on a way of doing that without manipulating the page itself?

Upvotes: 0

Views: 384

Answers (1)

Xan
Xan

Reputation: 77591

You can write an extension for DevTools that would listen to chrome.devtools.panels.elements.onSelectionChanged event.

The event does not supply the element directly, but you can evaluate $0 to get process the selected element with chrome.devtools.inspectedWindow.eval (for example, in a content script).

This question may be of help with concrete code.

Upvotes: 4

Related Questions