Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to select all elements with a specific attribute? with TinyXPath

What is the XPath expression for selecting all elements with attribute A?

const char* xpath = "//\*/\*[@A]" 
like image 969
eugene Avatar asked Apr 11 '11 06:04

eugene


People also ask

How do you select all elements in a selenium document?

By adding '//*' in XPath you would be selecting all the element nodes from the entire document.

How do I select all child elements in XPath?

For the div element with an id attribute of hero //div[@id='hero'] , these XPath expression will select elements as follows: //div[@id='hero']/* will select all of its children elements. //div[@id='hero']/img will select all of its children img elements. //div[@id='hero']//* will select all of its descendent elements.

What is contain in XPath?

contains() is a Selenium function that searches for web elements that contain a specific text within an Xpath expression. The XPath function contains offers the ability to detect elements containing partial text. They are used in any condition on Xpath. Lets take an HTML code here: <html>


1 Answers

This XPath selects all elements that have an A attribute:

//*[@A] 
like image 65
Mads Hansen Avatar answered Oct 03 '22 03:10

Mads Hansen