Selenium IDE – Part II

In Part I we covered

  • Setting Up
  • Recording Tests
  • Playing Back Tests
  • Saving Test Cases
  • Resuming Recording
  • Saving Test Suites

All examples will use the sample site https://sites.google.com/site/example4selenium/.

Store Value

  • There are two ways to store values.
  • First, you can define custom variables
  • Custom Variables

  • Second you can use the drop-down ‘storeText’ option.
  • Store Option

  • Enter a variable name.
  • Enter Variable Name

  • Variables can be used by simply surrounding the variable name with ‘${ }’
  • Use Variables

  • Running this script will result in an insert of both variables separated with an ‘and’.
  • Variable Results

Debug

  • To debug a script insert a breakpoint.
  • Insert Breakpoint

  • Run the test case.
  • Run For Debug

  • The Continue button resumes the execution of the script.
  • The Step button steps through the test case one action at a time.

XPath

  • Selenium IDE can navigate html using XPath. If you are not familiar with XPath there is a beginners tutorial at http://www.w3schools.com/xpath/default.asp.
  • Instead of referring to the id of a target you can locate an element with XPath.
  • Text Area XPath

  • You can verify your XPath by clicking the ‘Find’ button. The element will be highlighted in the browser with flashing neon green if it exists.
  • If you want to select elements by position, you may want the following information. The traditional ‘//input[2]’ does not work all the time in Selenium IDE. If you can not locate your target element by index, use the following syntax ‘//input/following::input’. This syntax specifies the location of an input that follows another input. This will result in the selection of the second input. Simply add another ‘/following::’ to get to the next matching element. Unfortunately this syntax is quite verbose.

Exporting Scripts