Dashboard > Wonder > ... > How to Develop Selenium Tests > Selenium Command Examples
  Wonder Log In View a printable version of the current page.  
  Selenium Command Examples
Added by Kieran Kelleher, last edited by Kieran Kelleher on Jul 02, 2008  (view change)
Labels: 
(None)

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

Site running on a free Atlassian Confluence Open Source Project License granted to ObjectStyle. Evaluate Confluence today.
Powered by Atlassian Confluence, the Enterprise Wiki. (Version: 2.5.4 Build:#809 Jun 12, 2007) - Bug/feature request - Contact Administrators