-1

I was using Firepath to evaluate my custom Xpath. I understand that Firebug and Firepath no longer work on latest versions of Firefox. Now you have to use Developer Tools and copy and paste XPath to the console.

How can I evaluate my custom XPath in Firefox Developer Tools?

Appreciate any help.

clemens
  • 16,716
  • 11
  • 50
  • 65
user3329818
  • 31
  • 1
  • 6
  • 1
    To evaluate an XPath, run `$x("custom xpath")` in the console (F12). – Florent B. Nov 21 '17 at 17:33
  • Thank you i will try that should i expect a message or will it highlight the code? – user3329818 Nov 21 '17 at 17:38
  • Possible duplicate of [how to inspect element in selenium3.6 as firebug is not an option any more for FF 56?](https://stackoverflow.com/questions/46700764/how-to-inspect-element-in-selenium3-6-as-firebug-is-not-an-option-any-more-for-f/46702281#46702281) – undetected Selenium Nov 22 '17 at 11:46

2 Answers2

0

Use document.evaluate, for example:

document.evaluate('//td[contains(@class, "owner")]//div[@class="user-details"]/a', document, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue.innerHTML

If you run it on this page, it will show your username. Running it on some other page, that does not have similar element, would show error:

TypeError: document.evaluate(...).singleNodeValue is null

More generically, document.evaluate returns an object of type XPathResult, which can be used to retrieved various aspects of evaluated XPath. You can also customize result type (4th argument).

timbre timbre
  • 12,648
  • 10
  • 46
  • 77
0

Go to Firefox menu -> web developer -> web console Then at the bottom of the console there is place to type command, type

First allow pasting in console.

$x("allow pasting") 

Then, use your xpath

$x("Your xpath here")

mouse hover on start icon will highlight the element in the webpage

Jyoti Prakash
  • 3,921
  • 3
  • 21
  • 24