Search for elements by XPath selectors

REOPENED
Unassigned

Status

()

Firefox
Developer Tools: Inspector
P2
enhancement
REOPENED
4 years ago
a month ago

People

(Reporter: Géza Búza, Unassigned)

Tracking

(Blocks: 2 bugs)

26 Branch
Points:
---
Dependency tree / graph

Firefox Tracking Flags

(Not tracked)

Details

(Reporter)

Description

4 years ago
User Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:26.0) Gecko/20100101 Firefox/26.0 (Beta/Release)
Build ID: 20131205075310

Steps to reproduce:

As a developer I want to find elements by typing a CSS or XPath expression. It could came handy when debugging or when testing.
I would like to see support in DevTools for it.


Actual results:

Currently I can achieve this using JavaScript eg. jQuery.


Expected results:

I expect to have an input text filed for the CSS / XPath expression and a results list for the matched elements.
(Reporter)

Updated

4 years ago
Severity: normal → enhancement
Component: Untriaged → Developer Tools: Inspector
OS: Windows 7 → All
Hardware: x86_64 → All
It's already possible to search via CSS selectors in the Inspector, as that's what is accepted by the search field there.

Renaming this bug to be about XPath only, since CSS selector search already exists.
Status: UNCONFIRMED → NEW
Ever confirmed: true
Summary: Inspect elements by CSS and XPath selectors → Search for elements by XPath selectors
(Reporter)

Comment 2

4 years ago
Sorry, I did not see that CSS selector search is already implemented. I just have checked it, and it actually works very well.
(In reply to Géza Búza from comment #2)
> Sorry, I did not see that CSS selector search is already implemented. I just
> have checked it, and it actually works very well.

Do you think XPath is also needed, or does selector search seem sufficient?  My guess is that the number of web developers that know XPath well is much smaller than those that know CSS selectors.
Chrome is in the process of removing XSLT [1]. I suspect that XSLT is the largest [2] feature of browsers that has ever been actually removed.
Sure, XSLT != XPath, but they're from the same family, and I'm not sure we need to add XPath features now.

[1]: https://groups.google.com/a/chromium.org/forum/#!topic/blink-dev/zIg2KC7PyH0[101-125-false]
[2]: In terms of lines of code
(Reporter)

Comment 5

4 years ago
@Ryan, @Joe I understand your concerns and basically agree with you. But I am going to describe why it could be useful for me.

As a web developer when I have to write automated tests I often need to check the existance of a content in the current page. Let's say I need to look for a SPAN element with content in it. Here I can use an XPath like this:
//span[text()='some content']
The same check with CSS selectors would involve more coding, because first I search for all SPAN, then read the text content from code one by one and check if one of the is equals to "some content".

To sum up, I think Xpath is not a must have feature, but sometimes it could come handy.
(In reply to Géza Búza from comment #5)
> To sum up, I think Xpath is not a must have feature, but sometimes it could
> come handy.

Selenium, right?

I guess we *could* have devtools try an XPath match if querySelector failed, which would be low UI impact. But I'm still concerned that this is a deprecated feature. If FF follows Chrome in removing XSLT, and XPath comes next then we'd need to remove this feature.
(Reporter)

Comment 7

4 years ago
That's right, I use Selenium.

As far as I know XPath does not depend on XSLT, but XML document and XML Schema, so you can safely remove XSLT. And it is not so old piece of technology, because if you take a look at http://www.w3.org/TR/xpath20/ you can see that the second version was approved in 2010.

Maybe some kind of usage statistic could help to decide.
Anyway, do what you think is the best! :)
fwiw, we have the $x() helper which returns an array of matching nodes in the Console.
(Reporter)

Comment 9

4 years ago
Thanks @Rob. That's fair enough.
No feedback on this for a while, and we don't have in our current plan to add support for XPATH now.
Status: NEW → RESOLVED
Last Resolved: a year ago
Resolution: --- → WONTFIX
Blocks: 991806
Patrick, I got several requests lately related to FirePath not working anymore. Most of them are related to bug 987877, but some of them[1][2] are related to this one.

Joe's point that XPaths are a deprecated feature might become valid in the future, though the latest spec.[3] is newer than his post and the thread related to Google's intent to deprecate XSLT[4] contains comments indicating that there is no intent to deprecate XPath.

Therefore, I reopen this issue.

Sebastian

[1] http://stackoverflow.com/q/41992056/432681
[2] https://groups.google.com/d/msg/firebug/Q6eyvGt6hyI/yFFO5ji-CAAJ
[3] https://www.w3.org/TR/xpath-30/
[4] https://groups.google.com/a/chromium.org/forum/#!topic/blink-dev/zIg2KC7PyH0%5B1-25%5D
Status: RESOLVED → REOPENED
Resolution: WONTFIX → ---
Thanks Sebastian. These are good points.
It is also a Firebug and Chrome gap.
Let's triage this as a P2 enhancement.
Priority: -- → P2

Comment 13

5 months ago
There is also the case of XPath being the only method to walk the DOM up and down.  There are many circumstances especially when testing that there is no ID or easy CSS way to get to the object.  So, you have to do an XPath search for Value= or Text=, walk up the DOM, then back down to get to the object you want.  I find XPath to be critical, and FirePath is my number one used add-in.
Comment hidden (me-too)

Updated

4 months ago
Blocks: 1267303

Comment 15

4 months ago
We need both (Xpath and Css).

And i agree :
The best tool with firebug is "FirePath", easy to use and work the both type.
We need the same thing in Dev ToolBar.

"There is also the case of XPath being the only method to walk the DOM up and down." :
(for me) Xpath is harder to understand and the selector provided is not always the most accurate.
I use in this case a tool provided by the quasi defunct Autopager addon (https://addons.mozilla.org/en-US/firefox/addon/autopager/).
Its built in function to create a XPath by click some links on the pages is very intuitive and useful.
If it is possible it should be a great improvement to include something similar to the Dev Toolbar.
You need to log in before you can comment on or make changes to this bug.