XPath search isn't working for some expressions
Categories
(DevTools :: Inspector, enhancement, P3)
Tracking
(firefox79 verified)
| Tracking | Status | |
|---|---|---|
| firefox79 | --- | verified |
People
(Reporter: sebo, Assigned: sebo)
References
(Blocks 1 open bug, )
Details
Attachments
(2 files)
At Stack Overflow it was mentioned that it is currently not possible to find elements by index, that is for example (//div)[4] (the 4th <div> element in the document).
The reason for that is that is that the check for whether the search string is an XPath expression currently only covers strings starting with a slash.
Further research showed that also expressions like id("foo") (matching the element with ID foo) are valid.
Those expressions are working in the Chrome DevTools and I think it is reasonable to support them in Firefox, too.
Test case:
- Go to
data:text/html,<div><p><div id="div2"></div><p></div> - Open the DevTools Inspector
- Search for
(//div[2])orid("div2")
=> This should select the <div> element inside the <p> element.
To support them, the check could either be extended or be removed entirely. The latter would mean to always run the XPath search before the full text search, though, which might have performance implications.
Sebastian
Updated•1 year ago
|
| Assignee | ||
Comment 1•11 months ago
|
||
The limitation to expressions starting with a slash was lifted in order to allow searching via other possible XPath expressions like id("foo") or (//div)[2].
Updated•11 months ago
|
Pushed by abutkovits@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/03154d974c8a Extended support for XPath expressions in Inspector search. r=jdescottes
Comment 3•11 months ago
|
||
| bugherder | ||
Comment 4•11 months ago
|
||
Small gif of the implemented feature
Comment 5•11 months ago
|
||
Verified with 79.0b2 in Windows 10, macOS 10.15.5, Ubuntu 18.
Description
•