QA/Execution/Web Testing/Selenium IDE RC: Difference between revisions
No edit summary |
No edit summary |
||
Line 9: | Line 9: | ||
<br> | <br> | ||
==== | ==== 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). | 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). | ||
#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). <br> | |||
#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.<br> | |||
#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. <br> | |||
#Change the text from "Untitled" to the test case title. <br> | |||
#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. | |||
#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. ) | ( If there is a an easier way to create the full test suite from IDE we should document those instructions. ) | ||
<br> | <br> | ||
==== | ==== Set Up Selenium RC ==== | ||
#Download the Selenium RC zip from the Selenium HQ [http://seleniumhq.org/download/ downloads] page. 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. 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.<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 Windows<br> ==== | |||
#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. Below, the options are displayed on multiple lines for readability. | |||
java | java | ||
Line 54: | Line 45: | ||
"<base URL>" | "<base URL>" | ||
"<absolute path of the Selenium test suite>" | "<absolute path of the Selenium test suite>" | ||
"<absolute path of the results log>" | "<absolute path of the results log>" | ||
-timeout nnnn | |||
-timeout nnnn | |||
<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).
- 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).
- 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.
- 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.
- Change the text from "Untitled" to the test case title.
- 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.
- 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
- Download the Selenium RC zip from the Selenium HQ downloads page. 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. 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
- 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. 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.