- Forward


ECMAScript/JavaScript System Testing
Using Selenium-IDE


Prof. David Bernstein
James Madison University

Computer Science Department
bernstdh@jmu.edu

Print

Getting Started
Back SMYC Forward
  • Distribution:
    • Selenium-IDE is distributed as a Firefox plug-in
  • Setting Up:
    • Downloading the plug-in will start the installation process (which you will need to "Allow")
    • You may need to re-start Firefox to complete the installation
Test Cases and Tests/Test Suites
Back SMYC Forward
  • Test Cases:
    • Each test case is saved as an HTML file
  • Test Suites:
    • Each test suite is saved as an HTML file that refers to individual test cases (hence you must save the test cases before you can save the test suite)
The Process
Back SMYC Forward
  1. Start Firefox
  2. Start Selenium-IDE by clicking on selenium-ide-logo in the toolbar
  3. Create (or record) one or more test cases
  4. Save each test case
  5. Save the test suite
  6. Play the test suite
Test Cases
Back SMYC Forward
  • Contents:
    • A sequence of commands (each of which has 0, 1, or 2 parameters)
  • Encapsulation:
    • Each test case is encapsulated as an HTML table
    • Each command is encapsulated as a row (with two columns) in the table
  • Editing:
    • A test case can be edited using the IDE (which is convenient because you can get a complete list of Commands using the dropdown and help using the Reference tab)
    • A test case can also be edited using any text editor since it is encapsulated in HTML (which is convenient because you can easily create variants)
Locators (i.e., Locating Elements in a Document
Back SMYC Forward
  • By ID:
    • id=elementID
  • By Name:
    • name=elementName
  • Using the DOM:
    • dom=JavaScriptCode
  • Using XPath:
    • A language that is used for locating nodes in an XML document
Important Commands
Back SMYC Forward
  • Open a document:
    • open URL
  • Enter text in an input:
    • type locator value
  • Click on an element:
    • click locator
  • Fire an event:
    • fireEvent locator eventName
  • Make an assertion about text:
    • assertText locator pattern
  • Make an assertion about an element's attribute:
    • assertAttribute locator@attribute pattern
An Example Test Case
Back SMYC Forward

Based on the BMI Calculator Click here for a demonstration.

ecmascriptexamples/systemtesting/normal.html
 
An Example Test Suite
Back SMYC Forward

Based on the BMI Calculator Click here for a demonstration.

ecmascriptexamples/systemtesting/bmi-calculator-testsuite.html
 
About Recording
Back SMYC Forward
  • A Note:
    • Selenium-IDE starts in record mode (which you may want to stop by clicking on the record button)
  • Advantages of Recording:
    • Recording can help you get started and save some typing
  • Shortcomings of Recording:
    • Many important events are not fired (and, hence, must be added afterward)
    • Assertions must be added afterward
There's Always More to Learn
Back -