如何在Chrome或Firefox中获取Absolute XPath? [英] How to get Absolute XPath in Chrome or Firefox?
问题描述
如问题中所述,我需要绝对 Xpath,而不是相对的.
As written in the question I need the absolute Xpath and not the relative one.
我的意思是,我需要这样的东西:
I mean, I need something like this:
html/body/div[1]/section/div[1]/div/div/div/div[1]/div/div/div/div/div[3]/div[1]/div/h4[1]/b
而不是这样:
//*[@class='featured-box']//*[text()='Testing']
在两个浏览器上,当我检查代码并使用右键单击时,->复制XPath 我正在获取相对路径.
On both browsers when I inspect the code and I use right click -> copy XPath I am getting the relative Path.
请注意,我使用的是Firefox Quantum,不能使用firebug或firepath,因为它们不受支持.
Please note, I am using Firefox Quantum and I cannot use firebug or firepath because they are not supported.
推荐答案
Download this chrome extension: https://chrome.google.com/webstore/detail/xpath-helper/hgimnogjllphhhkhlmebbmlgjoejdpjl
然后,单击扩展名的图标,然后在选项卡窗口中出现两个框后,按住Shift键可在元素之间导航并查看xpath.
After that, click at icon of the extension and, after two boxes appers in the tab window, hold shift key to navigate between elements and see the xpath.
这篇关于如何在Chrome或Firefox中获取Absolute XPath?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!