The default bug view has changed. See this FAQ.

[markup view] Add "Copy XPath" context menu item for nodes

NEW
Unassigned

Status

()

Firefox
Developer Tools: Inspector
P3
normal
3 years ago
18 days ago

People

(Reporter: bgrins, Unassigned)

Tracking

(Blocks: 1 bug, {dev-doc-needed})

Trunk
dev-doc-needed
Points:
---

Firefox Tracking Flags

(Not tracked)

Details

Similar to "Copy Unique Selector" we could have an entry that copies the XPath for a node.
(Reporter)

Updated

3 years ago
Priority: -- → P3
I'm willing to bet that the only people that want this are WebDriver people. I wonder if the best place for this is a WebDriver extension?
See Also: → bug 1298359

Updated

7 months ago
Duplicate of this bug: 1298359

Comment 3

7 months ago
One notes the Chromium browser has 'Copy Xpath', but it apparently abbreviates.
//*[@id="switchdiv"]/table/tbody/tr[2]/td/table/tbody/tr[2]/td/table/tbody/tr[8]/td[5]

Comment 4

7 months ago
https://www.youtube.com/watch?v=ohY815wUz9o need Firebug, etc.
See also https://bugs.chromium.org/p/chromium/issues/detail?id=625710

Comment 5

7 months ago
http://stackoverflow.com/questions/24212548/how-to-get-the-absolute-xpath-for-an-element-within-firebug

Comment 6

7 months ago
https://getfirebug.com/firstrun#Firebug%202.0.17 says it will be merged into Firefox soon anyway.

Comment 7

7 months ago
As a footnote, I can now also turn the xpath into a Perl XML::TreePP path!
$ set '/html/body/div/div[3]/div[2]/div[2]/div[2]/table/tbody/tr[2]/td/table/tbody/tr[2]/td/table/tbody/tr[7]/td[5]'
$ echo $@|perl -pwle 's!/(\w+)!->{$1}!g'
->{html}->{body}->{div}->{div}[3]->{div}[2]->{div}[2]->{div}[2]->{table}->{tbody}->{tr}[2]->{td}->{table}->{tbody}->{tr}[2]->{td}->{table}->{tbody}->{tr}[7]->{td}[5]
Blocks: 991806
Keywords: dev-doc-needed
Comment hidden (me-too)
As far as we are aware the only call for this is people that use webdriver. I'm assuming that this is your use-case? In general I'm not sure I've seen use of XPath outside of webdriver for a while.

We're considering this bug as part of the firebug-gaps project (bug 991806) which closes off gaps where the builtin tools are missing functions that are in Firebug.

As an aside comments on Bugzilla are subject to Etiquette and Contributor Guidelines. https://bugzilla.mozilla.org/page.cgi?id=etiquette.html
Your comment violates point 2, point 3 and maybe point 1, please be more civil in the future.

Comment 10

2 months ago
> (In reply to Joe Walker [:jwalker] (needinfo me or ping on irc) from comment #1)
> I'm willing to bet that the only people that want this are WebDriver people.

We use this at our company, and I'm not sure I even know what WebDriver is.

We have a tool that is configured using XPaths, and we normally get these via Firebug.  Therefore, we have lost some vital functionality with the recent 'upgrade' that disabled Firebug for us!
(In reply to Mark Clements from comment #10)
> > (In reply to Joe Walker [:jwalker] (needinfo me or ping on irc) from comment #1)
> We have a tool that is configured using XPaths, and we normally get these
> via Firebug.  Therefore, we have lost some vital functionality with the
> recent 'upgrade' that disabled Firebug for us!

Reminder: e10s is still off in release by default, so Firebug works fine there. It still works anywhere where e10 is is off, which includes DevEdition and Nightly if the window is opened in non-e10s mode, so as far as I'm aware, you can still run Firebug on all releases of Firefox.
Correction: e10s is still off in release by default *if you have addons that don't work in e10s mode* (which include FB).

Comment 13

2 months ago
(In reply to Joe Walker [:jwalker] (needinfo me or ping on irc) from comment #11)
> (In reply to Mark Clements from comment #10)
> Reminder: e10s is still off in release by default, so Firebug works fine

You're right - my mistake.  I'd read the Firebug release notes which said it now just shows an upgrade notice and therefore started using the developer tools on the assumption that Firebug was no-longer available.  But having tested, it appears Firebug is still working.

My point still stands - there are other people who use this functionality.  But so long as we are able to continue using Firebug this is not such an urgent issue (so long as it is fixed before Firebug gets switched off).
Btw. Firebug additionally had an option 'Copy Minimal XPath' for elements with an 'id' attribute. It should be considered to also add that option, which is probably the more valuable one in regard of automatic testing.

Sebastian

Comment 15

18 days ago
+1 for this feature.

With the pending disappearance of firebug, and its xpath extension, there seems to be no good way to automatically determine xpaths for elements on a page. I use xpaths to parse, scrape, and test web sites using python code (independent of firefox itself, or selenium webdriver).

The converse functionality is also needed: after much search I did find the developer console function $x() that returns a list of xpath results on a page, but it would also be helpful to have a tool that shows those results in the inspect view automatically (as firebug's xpath extension did). Currently it doesn't appear possible to view multiple results, or things like '/text()' contents of elements, in the inspector.
You need to log in before you can comment on or make changes to this bug.