Selenium Command Examples

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

Using XPath Expressions as Locators

Examples

Click a link having css class 'selcreateteam'

 clickAndWait  //aWONDER:@class='selcreateteam'  
Add the first element of a list browser (aka. 'select' element) to the current selections. The list browser is identified by css class 'selbrowserlist'
 addSelection  //selectWONDER:@class='selbrowserlist'  value=0 
Add the third element of a list browser (aka. 'select' element) to the current selections. The list browser is identified by css class 'selbrowserlist'
 addSelection  //selectWONDER:@class='selbrowserlist'  value=2 
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 'selbrowserlist'
 addSelection  //selectWONDER:@class='selbrowserlist'  label=John Murphy 
Store the current value of an input field into a script variable. The input field is identified by the css class "selEditTeamteamName" and we are storing the current field value into a script variable named "varEditTeamteamName"
 storeValue  //inputWONDER:@class='selEditTeamteamName'  varEditTeamteamName 
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
 clickAndWait  link=$varEditTeamteamName  
Type the value 'abc' in the input field having class 'selinput'
 type  //inputWONDER:@class='selinput'  abc 
Store the value 'abc' in a script variable named var1
storeabcvar1

XPath Resources