问题
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