问题
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:
- For one selector only, change the dropdown value from selectors to rel XPath/abs Xpath/CSS sel in header.
- 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.
- 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