Click here to Skip to main content
Click here to Skip to main content

Running Selenium HTML (Selenese) Test Cases in Parallel

, 1 Dec 2009
Rate this:
Please Sign up or sign in to vote.
This article will explain how to reduce time for the execution of Selenium HTML test cases without using Selenium Grid.

Introduction

This article explains how to run Selenium HTML (Selenese) based test suites in parallel reducing the execution time without using Selenium Grid.

Background

Currently Selenium Grid offers running Selenium tests written in C#, Java, Ruby, and PHP. But there are no client drivers available for Selenese test cases. The idea presented in this article is a workaround for running the Selenese test cases in parallel for reducing the execution time.

Real Scenario: Before this approach, we executed our Selenese tests in Selenium Functional Test Runner and it took almost 2 hours to execute 8 test suites parallel in a browser. With this approach, we have reduced the time to 15 minutes to execute the same 8 test suites.

Using the Code

The attached zip file is a sample ANT build script that executes the test suites by initializing them in different Selenium Remote Controls in parallel. To setup the environment, you need the following tools to be installed on your machine :

  • ANT
  • Psexec
  • Selenium Remote Control
  • Subversion (optional: if the test cases are in subversion repository)

The following snippet sets the required paths according to your environment. E.g. path to Selenium Server, base URL, path to Selenium tests and path to save generated Selenium reports:

<!-- Path to Selenium Server Binaries-->
<property name="SeleniumServerPath" value="C:\Path-to-Selenium-Server" />
<!--Path to base url-->
<property name="baseURL" value="https://url-to-your-application"/>
<!--<Path to Selenium Tests-->
<property name="SeleniumTestsPath" value="C:\Path-to-SeleniumTests"/>
<!--Path to Selenium Results-->
<property name="SeleniumReports" value="C:\Path-to-Reports" />

The following snippet updates the test files from subversion and calls the target for FirstTestSuite file:

<!-- This target will be used to update your selenium tests from Subversion -->
<target name="svn">
<exec dir="${SeleniumTestsPath}" executable="svn">
<arg line="update --username usr --password pwd" />
</exec>
<antcall target="FirstTestSuite">
</antcall>
</target>

The following snippet initializes the first Selenium Server on port 4444 and second Selenium Server on port 4445 to execute the first and second test suite file in parallel. (Note: Place the user extension file in the same folder where test suite file is located.)

Please observe that Selenium Server is initialized using psexec so that ant can get the control back to initialize the second Server. Moreover, a sleep time of 15 seconds is included in order to have sufficient time for first Selenium Remote control to prepare the new Firefox profile before initializing the second Selenium Remote Control. Otherwise, it will throw an error that Firefox profile cannot be created.

<target name="FirstTestSuite">
<exec dir="${SeleniumServerPath}" executable="psexec.exe" spawn="true">
<arg line="-d -i java -jar
selenium-server.jar -port 4444 -singlewindow -htmlSuite *firefox ${baseURL}
${SeleniumTestsPath}\FirstTestSuite.html
${SeleniumReports}\Results_FirstTestSuite.html" /> 
</exec>
<sleep seconds="15" />
<antcall
target="SecondTestSuite"/>
</target>
<target name="SecondTestSuite">
<exec dir="${SeleniumServerPath}" executable="psexec.exe" spawn="true">
<arg line="-d -i java -jar
selenium-server.jar -port 4445 -singlewindow -htmlSuite *firefox ${baseURL}
${SeleniumTestsPath}\SecondTestSuite.html
${SeleniumReports}\Results_SecondTestSuite.html" /> 
</exec>
<sleep seconds="15" />
<antcall
target="ThirdTestSuite"/>
</target>

Points of Interest

Large test suite files can be divided into smaller parts in order to execute them in parallel. This approach helps until Selenium Grid comes with an HTML client driver to execute the Selenese test cases in parallel.

History

  • 1st December, 2009: Initial post

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

Share

About the Author

Obaid Malik

Pakistan Pakistan
No Biography provided

Comments and Discussions

 
GeneralMy vote of 4 Pinmemberpsamagal6-Dec-12 10:12 
Questionwhat is the way to run it? PinmemberTanvir Afzal14-Nov-12 22:47 
QuestionCant get multiple windows opened Pinmemberkrishnam_selenium9-Jul-12 23:25 
Questionerror in IE PinmemberMember 827595922-Nov-11 11:37 
QuestionOnly single browser session is created PinmemberMember 840431916-Nov-11 5:16 
QuestionRunning Selenium HTML (Selenese) Test Cases in Parallel PinmemberMember 830905511-Oct-11 8:10 
QuestionBrilliant, Pinmemberjust_do_it_5728-Sep-11 4:39 
GeneralMy vote of 1 Pinmembersantoshnagp99914-Dec-09 2:56 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

| Advertise | Privacy | Mobile
Web01 | 2.8.140827.1 | Last Updated 1 Dec 2009
Article Copyright 2009 by Obaid Malik
Everything else Copyright © CodeProject, 1999-2014
Terms of Service
Layout: fixed | fluid