What is the significance of the attribute xpath=“1” while constructing locators for Selenium tests

不羁的心 提交于 2021-01-29 08:46:00

问题


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

HTML:

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?


回答1:


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.



回答2:


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.



来源:https://stackoverflow.com/questions/65365459/what-is-the-significance-of-the-attribute-xpath-1-while-constructing-locators

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