ABOUT US

|

SUPPORT

|

BLOGS

 

 

DEVELOPER BLOG

 

 

 

 

 

 

 

Running Selenium Tests from the Command Line

 

Anthony Scotney

 

 

 

 

 

Running Selenium tests from the command line on Windows 7 can be slightly challenging simply due to the permissions system. By default Windows 7 tends to be locked down and there is conflicting information out there on exactly what steps to take to get Selenium tests running. The intention is that this article will provide some help for people trying to run Selenium Test Suites from the command line on Windows 7 (and other Windows versions).

1) Create a Selenium HTML test

Create a simple Selenium test (or ten) to add to your test suite. Creating a Selenium test is easy in LiquidTest. See our LiquidTest documentation on “how to record Selenium HTML tests“.

2) Create a Selenium Test Suite

Because HTML is essentially a content formatting language it contains little scope to tell any executing program exactly what to do outside of basic presentation. With this in mind and given that Selenium supports the HTML test format, the Selenium team came up with Selenium Test Suites to tell the Selenium runner (Selenium RC/Server) what tests to execute and the order of execution. Selenium Test Suites are fairly straight forward. In their simplest form they contain an HTML Table (TABLE), with a Row (TR) and some Table Data (TD).

<html>
	<head>
		<title>My Application Test Suite</title>
	</head>
	<body>
		<table> 
			<tr><td><b>Suite Of Tests</b></td></tr> 
			<tr><td><a href="./Test1.html">Test Example</a></td></tr>
		</table> 
	</body>
</html>

Notice that the tests can be grouped with the first Table Row, and then the preceding rows link to the actual test cases. This formatting helps with both execution ordering of test cases and to attach meaningful data to the results file output by the Selenium RC/Server.

3) Executing Selenium Test Suites from the Command Line

Security and Internet Explorer: Due to Windows 7 security, running tests as anything but Administrator produces sketchy results at best. I had numerous problems with Internet Explorer. Firstly Internet Explorer was loading Selenium RC/Server with many script errors regardless of configuration. The tests never replayed in this state. Firefox fared better in that it ran and produced the necessary results file. To avoid security issues with Selenium RC/Server ensure that any tests you are executing from the Command Line are through an Administrator Command Prompt (right-click on the Command Prompt and select “Run as Administrator”.

Administrator command line

Creating a Windows Batch file to run your Selenium Test Suite
To make life a little easier we will create a simple batch file to save writing the command out by hand for each Selenium Test Suite execution. The batch file consists of Java’s JAR command (ensure Java is in your System PATH or use the full file location to your Java bin directory). We specify to Selenium RC/Server that we wish to run a Test Suite, targeting Internet Explorer with a default URL of google.com (for our test) and then we specify where our Selenium Test Suite is located, where we want our Results file written and finally the Port for executing the communication.

java -jar selenium-server-standalone-2.0b3.jar -htmlSuite "*iexplore" "http://www.google.com" "D:\selenium-2\TestSuite.html" "D:\selenium-2\results.html" -port 4445
pause

The action..
When running a Selenium Test Suite, the browser you’re targeting will open and the test will replay.

Selenium Server / RC running on the command line

Selenium Server running test

4) Selenium test execution Results File

Selenium will start up and execute the Test Suite and write a Results file to the location you specified. The Results file looks like the following:

Selenium Server / RC - Test execution results

Selenium individual test details

Hopefully this example will be enough to get you started with running your Selenium HTML tests from the command line. For information on how to run your Selenium JUnit tests against the Selenium Server from within the Eclipse IDE please view the tutorial here..

 

 

These icons link to social bookmarking sites where readers can share and discover new web pages.
  • Digg
  • del.icio.us
  • StumbleUpon
  • Reddit
  • DZone
  • TwitThis
  • email
 Comments (0)

 

 


 

 

No comments yet

Add Comment..

 

 

About this blog..

 

This is an informal place for the team at JadeLiquid to discuss software, the rotation of the earth and other things usually discussed in the JadeLiquid corridors.

 

 

 

Subscribe: By Feed  By Email

 

 

 

 

 

Categories

 

 

JadeLiquid

LiquidTest

 

 

Software Testing

 

 

WebRenderer

 

 

 

 

Recent Posts

 

 

Selenium 2 / WebDriver support coming soon to LiquidTest..
Running Selenium Tests from the Command Line
LiquidTest 3.0 with Selenium support ships!
Setting up Atlassian Bamboo to run automated Web 2.0 tests
888 installer builds and 7469 code checkins later LiquidTest 2.0 ships!

 

 

 

 

 

Popular Posts

 

 

Testing complex Ajax content
Running Selenium Tests from the Command Line
Setting up LiquidTest with Subversion and Hudson (Continuous Integration) - part 1
Creating Data-Driven Functional Tests with LiquidTest
One tool to rule them all - Reducing team division
Setting up LiquidTest with Subversion and Hudson (Continuous Integration) part 2
Is manual testing crippling your development project?
Eclipse and LiquidTest UI Introduction
Protecting investment: Tests that do not break with page changes
Testing Dynamic Elements – Having a Plan B

 

 

 

 

 

Archives

 

 

May 2011 (2) April 2011 (1) November 2010 (2) March 2010 (1) February 2010 (1) November 2009 (1) October 2009 (1) September 2009 (2) August 2009 (1) July 2009 (1) June 2009 (1) April 2009 (1) March 2009 (1)

 

 

 

 

 
   News / Events

 

 > LiquidTest EOL Announcement - Info
 > LiquidTest Release 3.0! - Available
 > Visual Studio Plugin Released! - Release
 > Cruise Control .NET Integration - Info
 > Automate your Dev/Test Process - Webinar
 > Is manual testing crippling your project? - Blog
 > Testing complex Ajax content - Blog
 
 
   Recently Added Content  
 
 > Run LiquidTest's on Selenium RC/Server - Info
 > Setting up LiquidTest with Maven - Blog
 > Officially Supported Ajax Frameworks - Info
 > Atlassian Bamboo Integration - Tech
 > Setting up LiquidTest with SVN and Hudson - Blog
 > Creating Data-Driven Functional Tests - Blog
 > Reducing Test Maintenance - Blog
 
 
  Copyright JadeLiquid Software - 2014