Selenium Command Examples

Using XPath Expressions as Locators

Examples

Click a link having css class 'sel_create_team'

clickAndWait //a[@class='sel_create_team']  

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'

addSelection //select[@class='sel_browser_list'] 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 'sel_browser_list'

addSelection //select[@class='sel_browser_list'] 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 'sel_browser_list'

addSelection //select[@class='sel_browser_list'] label=John Murphy

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"

storeValue //input[@class='sel_EditTeam_teamName'] var_EditTeam_teamName

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=${var_EditTeam_teamName}  

Type the value 'abc' in the input field having class 'sel_input'

type //input[@class='sel_input'] abc

Store the value 'abc' in a script variable named var1

store abc var1

XPath Resources

Enter labels to add to this page:
Please wait 
Looking for a label? Just start typing.