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 9: Line 9:
<br>  
<br>  


==== 1. Create the test suite. ====
==== Create a test suite file ====


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


===== To create a test suite file  =====
#Create an empty test suite file as follows: In SIDE select File &gt; 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). <br>  
 
#In a text editor open the test suite file and find the line &lt;tr&gt;&lt;td&gt;&lt;a href="../../.."&gt;Untitled&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;. &nbsp;Copy the line for each test case the suite will run.<br>  
a. Create an empty test suite file as follows: In SIDE select File &gt; 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). <br>  
#Replace ../.. in the href with the test case file name.&nbsp; The directory name can be omitted or be ./ (dot slash) since the test case and suite are in the same directory. <br>  
 
#Change the text from "Untitled" to the test case title. <br>  
b. In a text editor open the test suite file and find the line &lt;tr&gt;&lt;td&gt;&lt;a href="../../.."&gt;Untitled&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;. &nbsp;Copy the line for each test case the suite will run.<br>  
#Above the test cases find the line &lt;tr&gt;&lt;td&gt;&lt;b&gt;Test Suite&lt;/b&gt;&lt;/td&gt;&lt;/tr&gt; and replace "Test Suite" with an appropriate test suite title.  
 
#Confirm the test suite file works by running it in SIDE: File &gt; Open Test Suite.&nbsp; Run the entire test suite using the run icon with '''three dark green bars'''.
c. Replace ../.. in the href with the test case file name.&nbsp; The directory name can be omitted or be ./ (dot slash) since the test case and suite are in the same directory. <br>  
 
d. Change the text from "Untitled" to the test case title. <br>  
 
e. Above the test cases find the line &lt;tr&gt;&lt;td&gt;&lt;b&gt;Test Suite&lt;/b&gt;&lt;/td&gt;&lt;/tr&gt; and replace "Test Suite" with an appropriate test suite title.  
 
f. Confirm the test suite file works by running it in SIDE: File &gt; Open Test Suite.&nbsp; 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. )  
( If there is a an easier way to create the full test suite from IDE we should document those instructions. )  


<br>
<br>  


==== Install Selenium RC  ====
==== Set Up Selenium RC  ====


a. Download the Selenium-RC zip from the OpenQA.org Selenium-RC downloads page.  
#Download the Selenium RC zip from the Selenium HQ [http://seleniumhq.org/download/ downloads] page.&nbsp; Unzip to a convenient location.
#In the Selenium Remote Control folder open the selenium-server-* subfolder and check that it contains selenium-server.jar.
#Create a file that contains all user extensions required by the tests.&nbsp; Name the file user-extensions.js and save in the directory containing selenium-server.jar.&nbsp; If they required only one user extension the user extension file may be copied and renamed.&nbsp;&nbsp;If multiple user extensions are needed copy/append them into one file.&nbsp; 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.<br>
<pre>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)
</pre>
==== Running the Scripts in&nbsp;Windows<br>  ====


b. Unzip the download.
#Open a Windows command line window and set the current directory to the location of selenium-server.jar.  
 
#Enter the command "java -jar selenium-server.jar" with the necessary options on one line.&nbsp; Below, the options are displayed on multiple lines for readability.
c. In the directory containing Selenium RC find selenium-server.jar. In version 1.0.1 it is in the subdirectory selenium-server-1.0.1.  
 
d. If any user extensions are required (remember that the While and Goto commands come from a user extension): a. Append all needed extensions together into one file named user-extensions.js IMPORTANT: goto_sel_ide.js, which defines While and Goto commands, does not work in RC. Instead, use goto_sel08.js found on the same Selenium download page. b. Save user-extensions.js in the same subdirectory as selenium-server.jar  
 
==== Run the script  ====
 
a. Open a Windows command line window. Navigate to the directory containing selenium-server.jar.
 
b. Enter the following at the command line, modified as necessary:


       java  
       java  
Line 54: Line 45:
             "&lt;base URL&gt;"  
             "&lt;base URL&gt;"  
             "&lt;absolute path of the Selenium test suite&gt;"  
             "&lt;absolute path of the Selenium test suite&gt;"  
             "&lt;absolute path of the results log&gt;"
             "&lt;absolute path of the results log&gt;"
 
        -timeout nnnn
-timeout nnnn  
 
Notes:


In actuality the command is entered as one continuous line. It is written with multiple lines for readability.
<br>


-userExetensions A simple script without user extensions does not need "-userExtensions user-extensions.js".  
-userExetensions A simple script without user extensions does not need "-userExtensions user-extensions.js".  

Revision as of 01:16, 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>" 
           "<absolute path of the Selenium test suite>" 
           "<absolute path of the results log>"  
       -timeout nnnn


-userExetensions A simple script without user extensions does not need "-userExtensions user-extensions.js".

-htmlSuite Help can be displayed for the -htmlSuite parameter by using it without arguments: java -jar selenium-server.jar -htmlSuite

  • chrome specifies Firefox as the browser to run the tests against, or *iehta specifies Internet Explorer as the browser. (These values are for RC 1.0.1. The values in 1.0.Beta 2 are *firefox and *iexplore)

The <base URL> argument is required, whether or not it's needed by the script. For example: https://addons.mozilla.org, or http://www.ebay.com

The results log is created in an html format, and the path should have an html extension. The first part of the log lists the script The second part of the log lists the execution and echo lines displayed in the bottom half of the SIDE window during runtime.

Once the script finishes RC immediately creates the first part of the log file. The second part off the log is created after a very long delay.

-timeout The timeout parameter needs to specify, in seconds, the expected time the script will run. The default timeout is 1800 seconds (30 minutes). If the script isn't finished within the timeout period selenium-server terminates with the error HTML suite exception seen: org.openqa.selenium.server.SeleniumCommandTimedOutException


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.