Html 如何获取 Firebug 中元素的绝对 XPath?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/24212548/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How to get the absolute XPath for an element within Firebug?
提问by user3738879
I used to see the absolute XPath for an element within Firebug. E.g. something like this:
我曾经在 Firebug 中看到某个元素的绝对 XPath。例如这样的事情:
html/body/div[2]/table/tbody/tr/td
When I select a certain element in a table using Firebug, then hover around the highlighted code inside the HTMLpanel I can't see the XPath anymore.
当我使用 Firebug 选择表格中的某个元素,然后将鼠标悬停在HTML面板内突出显示的代码上时,我再也看不到 XPath。
How to get Firebug to display the XPath again as a tooltip or any other way?
如何让 Firebug 以工具提示或任何其他方式再次显示 XPath?
回答by Sebastian Zartner
The tooltips for elements within the HTMLpanelwere removed in Firebug 2.0, because there were repeatedrequestssaying these tooltips were rather annoying than helpful.
在 Firebug 2.0中删除了HTML面板中元素的工具提示,因为有重复的请求说这些工具提示很烦人而不是有用。
If you need the XPath of an element, you can right-click it and choose Copy XPathfrom the context menu to copy the absolute XPath of the element to the clipboard.
如果需要元素的 XPath,可以右键单击它并从上下文菜单中选择复制XPath,将元素的绝对 XPath 复制到剪贴板。
For elements with and id
attribute there's also a new option in Firebug 2.0 to copy a short XPath called Copy Minimal XPath.
对于具有 和id
属性的元素,Firebug 2.0 中还有一个新选项可以复制一个名为Copy Minimal XPath的短XPath。
回答by Jeremiah
Firepathis a very nice extension to Firebug which can help with CSS and XPath references.
Firepath是 Firebug 的一个非常好的扩展,它可以帮助处理 CSS 和 XPath 引用。
回答by Rohit Rawat
Uncheck the Option of "Generate absolute Xpath":
取消选中“生成绝对 Xpath”的选项: