Wiki source code of Selenium Command Examples

Version 20.1 by Kieran Kelleher on 2008/07/02 15:10

Hide last authors
Kieran Kelleher 18.1 1 == Using XPath Expressions as Locators ==
2
3 === Examples ===
4
Kieran Kelleher 6.1 5 Click a link having css class 'sel//create//team'
6
Kieran Kelleher 20.1 7 | clickAndWait | ~/~/aWONDER:@class='sel//create//team' | |
Kieran Kelleher 6.1 8 Add the first element of a list browser (aka. 'select' element) to the current selections. The list browser is identified by css class 'sel//browser//list'
Kieran Kelleher 20.1 9 | addSelection | ~/~/selectWONDER:@class='sel//browser//list' | value=0 |
Kieran Kelleher 6.1 10 Add the third element of a list browser (aka. 'select' element) to the current selections. The list browser is identified by css class 'sel//browser//list'
Kieran Kelleher 20.1 11 | addSelection | ~/~/selectWONDER:@class='sel//browser//list' | value=2 |
Kieran Kelleher 18.1 12 Add the item named "John Murphy" of a list browser (aka. 'select' element) to the current selections. The list browser is identified by css class 'sel//browser//list'
Kieran Kelleher 20.1 13 | addSelection | ~/~/selectWONDER:@class='sel//browser//list' | label=John Murphy |
Kieran Kelleher 18.1 14 Store the current value of an input field into a script variable. The input field is identified by the css class "sel//EditTeam//teamName" and we are storing the current field value into a script variable named "var//EditTeam//teamName"
Kieran Kelleher 20.1 15 | storeValue | ~/~/inputWONDER:@class='sel//EditTeam//teamName' | var//EditTeam//teamName |
Kieran Kelleher 18.1 16 Use a stored variable later in the script (on a different page or whatever) to click a dynamic hyperlink that uses the stored value as the hyperlink text
Kieran Kelleher 19.1 17 | clickAndWait | link=$var//EditTeam//teamName | |
18 Type the value 'abc' in the input field having class 'sel//input'//
Kieran Kelleher 20.1 19 | type | ~/~/inputWONDER:@class='sel//input' //| abc |
20 Store the value 'abc' in a script variable named var1
21 |store|abc|var1
Kieran Kelleher 14.1 22
Kieran Kelleher 18.1 23 === XPath Resources ===
Kieran Kelleher 14.1 24
Kieran Kelleher 18.1 25 * [[http://www.w3schools.com/xpath/xpath_syntax.asp]]