How to find xpath of an element in firefox inspector

后端 未结 10 723
清酒与你
清酒与你 2020-12-14 05:57

In Firefox 50.1, Firebug is no longer available so I have to use the inspector but I cannot find copy ---> xpath option that was available in Firebug. How can I find the xpa

相关标签:
10条回答
  • 2020-12-14 06:32

    This is an old question but I'm glad to say that since FF 75 it supports searching by XPath, look at documentation. Here is a link to their blog entry

    0 讨论(0)
  • 2020-12-14 06:33

    The bug related to losing ability to 'copy XPath' from firefox inspector is fixed, verified in Firefox 56 beta, and verified in Firefox 57 alpha: https://bugzilla.mozilla.org/show_bug.cgi?id=987877

    0 讨论(0)
  • 2020-12-14 06:35

    Xpath Using Firefox Console: **
    Answer referenced from **Xpath Using Firefox Console in selenium webdriver

    Steps:

    Press F12( common for all browsers), Now firefox open developer tool like below.

    1. Naviagte to console tab

    2. On the console editor we can verify our Xpath

    3. For verifying xpath we have to use our xpath in following format : $x("xpath")
    0 讨论(0)
  • 2020-12-14 06:38

    I know that this doesn't answer directly to the question but it helped me a lot, use Pale Moon:

    1. Open any web page in Pale Moon browser
    2. Right click on an element of the page
    3. Select: "Inspect Element with Developer Tools" (a window shows up with element highlighted)
    4. Right click highlighted element
    5. Select: "Copy XPath"

    And there you have it. You will get a "full" xpath even if the element has an id.

    0 讨论(0)
  • 2020-12-14 06:43

    I would rather you study how to create xpath on your own to select the element you need. It's very simple and very very helpful specially when creating reusable methods/functions.

    Go and see the xpath tutorial at w3schools or wherever.

    Focus on the relationships between elements.

    Edit: Once you know how to construct a good-looking xpath, you can now test it using the browser console as mentioned by @mosaad. Still, you need to learn how to construct the xpath first. BTW, the copy xpath function wasn't available back in Jan '17. That is why I suggested he learn how to construct xpath. Even now that it is available though, I still suggest you learn because the xpath you get from those usually suck.

    0 讨论(0)
  • 2020-12-14 06:44

    You can't, firefox's inspector does not have such feature. However it does offer css selector which can be converted to xpath with various other tools.

    It should be noted however that these generated selectors (xpath or css) are not accurate or reliable and you should avoid using this feature for anything but rare edge cases.

    0 讨论(0)
提交回复
热议问题