Cheatography
https://cheatography.com
cheat sheet with xpath expressions
//input
finds all INPUT elements that are included in the web page |
//input[@aria-label='Search Catalogue']
finds all INPUT elements that have an ARIA-LABEL attribute with the
"Search Catalogue" value |
//button[@data-id='sortSelector']/span
1. finds all BUTTON elements that have a DATA-ID attribute with
the "sortSelector" value
2. for each element from the BUTTON list, find the SPAN elements that are direct children |
(//div[@class='listItem clearfix '])[2]//span
1. finds the DIV elements that have the CLASS attribute's value equal to "listItem clearfix"
2. gets the second element from the DIV elements list
3. finds all SPAN elements (direct children or not) that are inside of the second DIV |
//input[@id='globalQuery' and @name='q']
finds all INPUT elements that
1. have an ID attribute with the "globalQuery" value
2. have a NAME attribute with the "q" value |
//a[contains(@href, 'show_circulation')]
finds all A elements that have "show_circulation" included in the value of the HREF attribute |
//a[starts-with(@href, '/item/show_circulation')]
finds all A elements that have the HREF attribute's value starting with "/item/show_circulation" |
//input[not(@name='q')]
finds all INPUT elements that have the NAME attribute's value different than "q" |
|
|
(//div[@class='listItem clearfix '])[3]
1. finds all DIV elements that have the CLASS attribute's value equal to
"listItem clearfix"
2. selects the 3rd DIV element from the list of DIV elements |
(//div[@class='listItem clearfix '])[last()]
1. finds all DIV elements that have the CLASS attribute's value equal to
"listItem clearfix"
2. select the last DIV element from the list of DIV elements |
count(//div[@class='listItem clearfix '])
provides the count of all DIV elements that have the CLASS attribute's value equal to "listItem clearfix" |
//a[@class='extendSearch']/@testid
1. finds the A elements that have the CLASS attribute's value equal to
"extendSearch"
2. gets the value of the TESTID attribute for the A elements |
//a[@class='extendSearch']/text()
1. finds the A elements that have the CLASS attribute's value equal to "extendSearch"
2. get the value of the A elements |
//div[normalize-space(@class)='listItem clearfix']
1. finds the DIV elements that have a CLASS attribute
2. removes all spaces from the value of the CLASS attribute
2. finds the DIV elements that have the value of the CLASS attribute
(excluding spaces) equal to "listItem clearfix" |
//a[string-length(@href) > 70]
finds all A elements that have the HREF attribute value length greater than 70 characters |
|
Created By
test-able.blogspot.ca
Metadata
Favourited By
Comments
No comments yet. Add yours below!
Add a Comment
Related Cheat Sheets