How to get Absolute XPath in Chrome or Firefox?

偶尔善良 提交于 2020-04-30 05:07:30

问题


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

and not like this:

//*[@class='featured-box']//*[text()='Testing']

On both browsers when I inspect the code and I use right click -> copy XPath I am getting the relative Path.

Please note, I am using Firefox Quantum and I cannot use firebug or firepath because they are not supported.


回答1:


Download this chrome extension: https://chrome.google.com/webstore/detail/xpath-helper/hgimnogjllphhhkhlmebbmlgjoejdpjl

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.




回答2:


In chrome,for relative Xpath we use "Copy as Xpath" and for absolute Xpath use "Copy as full Xpath"



来源:https://stackoverflow.com/questions/48022185/how-to-get-absolute-xpath-in-chrome-or-firefox

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!