Selenium Command Examples

Version 18.1 by Kieran Kelleher on 2007/11/30 14:12

Using XPath Expressions as Locators

Examples

Click a link having css class 'selcreateteam'

 clickAndWait  //a@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  //select@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  //select@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  //select@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  //input@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  

XPath Resources