XPath: Equals
The equals operator (=) in XPath is used to select elements with specific attributes that match a given value. By specifying the attribute and its exact value within square brackets, you can target the elements that meet these criteria. This approach is helpful when you need to pinpoint elements that share the same tag but have different attributes.
You can use the following XPath:
This selects a list item (li) within an unordered list (ul) that has the id attribute equal to 'list-group-item'
Example 1: //ul[class='list-group']/li[id='list-group-item']
This targets a list item (li) with the class attribute equal to 'list-group-item border-secondary'
Example 2: //ul[class='list-group']/li[class='list-group-item border-secondary']
- Sample Item 0001
- Sample Item 0002
- Sample Item 0003
- Sample Item 0004
- Sample Item 0005
- Sample Item 0006
- Sample Item 0007
- Sample Item 0008
- Sample Item 0009
- Sample Item 0010