-5

Recently I stumbled on an element with an attribute xpath="1" within an angular based application.

HTML:

xpath=1

I'm unable to find any details about this attribute and it's possible impact and usage within a xpath/cssSelector for the Selenium based tests.

Can anyone help me out in any directions please?

Randy Casburn
  • 13,840
  • 1
  • 16
  • 31
undetected Selenium
  • 183,867
  • 41
  • 278
  • 352
  • Does this answer your question? [xpath = 1 in html means?](https://stackoverflow.com/questions/65324794/xpath-1-in-html-means) – wp78de Dec 19 '20 at 02:08
  • 1
    I have searched the angular code base and found nothing that refers to `xpath="1"`. – wp78de Dec 19 '20 at 02:58
  • wp78de: That's related, but there DebanjanB and I still wondered where these attributes were coming from, thus his question here. I've updated my [general answer](https://stackoverflow.com/a/65325284/290085) with a note about ChroPath and credited @RandyCasbum with a link to his [answer](https://stackoverflow.com/a/65367089/290085) here. Thanks. – kjhughes Dec 19 '20 at 15:01

2 Answers2

4

That attribute (xpath="1") is placed there by a browser extension named CHROPATH. It is provided by a feature they call Dynamic Attribute Support.

Scolling down the page one will find a text description of how to use the tool.

Scroll to Note: at the bottom of the page, or search for "Note:" within the page text. Take special attention to note #2. The entire note reads:

Note:

  1. For one selector only, change the dropdown value from selectors to rel XPath/abs Xpath/CSS sel in header.
  2. Tool will add xpath/css attribute to all the matching node(s) as per their sequential occurrence. For example, a matching node appearing second in the list will have xpath=2. And if verifying CSS then it will add css=2.
  3. Supports only those iframe which are from the same src.
Randy Casburn
  • 13,840
  • 1
  • 16
  • 31
  • So `xpath=1` or `xpath=2` isn't part of the actual element as far as the original HTML of the element is concerned. So can't be used for Selenium tests, agree @kjhughes ? – undetected Selenium Dec 19 '20 at 17:52
  • This is ChroPath creator, Sanjay Kumar. I have stopped development and support on ChroPath so it might not be working properly. Please upgrade to my new xpath tool SelectorsHub. –  Jan 03 '21 at 20:47
  • 1
    Good to know -Thanks Sanjay. – Randy Casburn Jan 03 '21 at 22:01
0

XPath="#" indicates the occurrence of the matching node on the web page. It is added by the plugin when you verify your own xpath. It add XPath = '1' for inspected element. I believe chropath is deprecated now and no support available on it.