QA/Execution/Web Testing/Selenium IDE RC: Difference between revisions

From MozillaWiki
Jump to navigation Jump to search
No edit summary
No edit summary
Line 96: Line 96:
*The output from the last execution of the echo appears in the command listing.
*The output from the last execution of the echo appears in the command listing.


The overall pattern is consistent across the two scenarios.  Attempt to store an echo's output in the command listing, unless a previous output exists.  If there is a previous output copy it to the current line in the execution log before saving the current output to the command listing.  
The overall pattern is consistent across the two scenarios: Attempt to store an echo's output in the command listing, unless a previous output exists.  If there is a previous output copy it to the current line in the execution log before saving the current output to the command listing.  


For a series of commands in a script that were executed sequentially the echo outputs will reflect the order of command execution. On the other hand, nested while-loops each with echos will not accurately show actual sequence of echo commands across the loops.<br>  
For a series of commands in a script executed sequentially the echo outputs in either the command listing or execution log will be in the same order they were generated.&nbsp; On the other hand, a series of echo commands not executed sequentialy due to flow control (nested while-loops, goto-If ) can combine echo outputs from <br>  


<br>  
<br>  

Revision as of 03:57, 28 January 2010

The page is still under construction. But should be finished soon.



Selenium IDE scripts may be run by Selenium Remote Control by using the -htmlSuite parameter. The link to official Selenium documentation is here.

These notes are based on Selenium RC 1.0.1.


Create a test suite file

RC uses a SIDE test suite, rather than a test case.  The test suite contains the file names of the test case(s) to run.  It exists in the same directory as the test case file(s).

  1. Create an empty test suite file as follows: In SIDE select File > New Test Suite. Select Save Test Suite As and save the file with an html extension in the same directory as the test case(s).
  2. In a text editor open the test suite file and find the line <tr><td><a href="../../..">Untitled</a></td></tr>.  Copy the line for each test case the suite will run.
  3. Replace ../.. in the href with the test case file name.  The directory name can be omitted or be ./ (dot slash) since the test case and suite are in the same directory.
  4. Change the text from "Untitled" to the test case title.
  5. Above the test cases find the line <tr><td><b>Test Suite</b></td></tr> and replace "Test Suite" with an appropriate test suite title.
  6. Confirm the test suite file works by running it in SIDE: File > Open Test Suite.  Run the entire test suite using the run icon with three dark green bars.

( If there is a an easier way to create the full test suite from IDE we should document those instructions. )


Set Up Selenium RC

  1. Download the Selenium RC zip from the Selenium HQ downloads page.  Unzip to a convenient location.
  2. In the Selenium Remote Control folder open the selenium-server-* subfolder and check that it contains selenium-server.jar.
  3. Create a file that contains all user extensions required by the tests.  Name the file user-extensions.js and save in the directory containing selenium-server.jar.  If they required only one user extension the user extension file may be copied and renamed.  If multiple user extensions are needed copy/append them into one file.  If the sequence in which they are listed is significant in the Selenium Core Extensions option in IDE, they must appear in the user-extensions.js file in the same sequence.
IMPORTANT: The user extension goto_sel_ide that defines the While and Goto commands does not 
work with Selenium RC.  Include the user extension goto_sel08.js instead.
(let's include a link here to the flow control user extensions when someone finds it)

Running the Scripts in Windows

  1. Open a Windows command line window and set the current directory to the location of selenium-server.jar.
  2. Enter the command "java -jar selenium-server.jar" with the necessary options on one line.  Below, the options are displayed on multiple lines for readability.
     java 
        -jar selenium-server.jar 
        -userExtensions user-extensions.js
        -htmlSuite 
           "*chrome" 
           "<base URL>" 
           "<Selenium test suite file>" 
           "<results log file>"  
       -timeout nnnn
Selenium Server Options
-user Extensions
 user-extensions.js is the only option
-htmlSuite
displays help text if no parameters are provided

1st parameter is the browser to run the script in. In RC 1.0.1 *chrome = Firefox, *iehta = IE.  (options in RC 1.0.2 are expected to be *firefox and *iexplore, respectively)

2nd parameter is base URL, same as base URL in IDE.  Required but may be a dummy URL if not relevant to the script.

3rd parameter is absolute path of the Selenium test suite file.

4th parameter is absolute path of the results log.  see below for more information
-timeout
time limit in seconds for the script to run.  Default is 1800 seconds (~30 minutes).  If the timeout is reached selenium-server terminates with the error HTML suite exception seen: org.openqa.selenium.server.SeleniumCommandTimedOutException


Results Log File

  • File is created in XML format and name should use .html file extension.
  • The upper section lists the script commands and outputs from some executions of echo commands.
  • The lower section is the command execution runtime log.
  • After the script finishes RC immediately creates the first part of the log file. There may be a long delay while the remainder of the log is created.
Echo Command  Output

Output from echo commands are displayed as part of the command's in the "3rd parameter" rather than in a separate line.  The results appear as one of two scenarios:

An echo command is executed only once:

  • The output appears with the echo command in the command listing (upper section).
  • In the execution log (lower section) the echo's 3rd parameter is empty.

An echo command is executed multiple times, such as in a while-loop.

  • In the execution log the first execution of a echo does not display the output.  Each additional execution of the echo displays the output from the previous execution.
  • The output from the last execution of the echo appears in the command listing.

The overall pattern is consistent across the two scenarios: Attempt to store an echo's output in the command listing, unless a previous output exists.  If there is a previous output copy it to the current line in the execution log before saving the current output to the command listing.

For a series of commands in a script executed sequentially the echo outputs in either the command listing or execution log will be in the same order they were generated.  On the other hand, a series of echo commands not executed sequentialy due to flow control (nested while-loops, goto-If ) can combine echo outputs from



Limitation observed

Echo output is shifted within the log file Echo statement output is shifted forward to the next call of the same statement. The script listing at the top of the results lists the last echo output. For example: The first execution of the "echo | ${myVar}" lists no output. The second execution of the same statement lists the output of the first execution. The output of last execution appears in the top of the log in the script listing. "echo | ${myVar2}" output is shifted forward each time it is executed. The shortcoming is minor in a linear script or echos within a loop. Analyzing the output log can become difficult when reviewing echos in different "contexts" such as inside and outside of a while loop, or selected echos executed conditionally when others are not.