Java Reference
In-Depth Information
The immediate issue raised by running within the JU nit 3 framework is the perfor-
mance of a test class. Each time JU nit calls a test method, JU nit also calls the setUp and
tearDown methods; this means starting and stopping a web browser, which is slow. We
remedy this performance problem in section 12.7.2, “Running Selenium tests with
JU nit 4.”
Another issue to consider when using the Selenium IDE is that you're recording
tests in Firefox 3. If your browser requirements are different from Firefox 3, what you
recorded may not play back the same in a different browser. Web pages can behave
differently, sometimes in a subtle manner, from browser to browser. In addition,
pages can contain scripts to customize behavior based on the host browser. Server-
side code can customize replies based on the agent making the request. Consider
these issues before generating code from Firefox with the Selenium IDE ; you may
need to write the tests from scratch, a la HtmlUnit, if your application has code paths
for a non-Firefox browser, such as Internet Explorer or Safari.
Next, we look at what it takes to run Selenium tests.
12.7
Running Selenium tests
Now that you know the basic concepts surrounding a Selenium test case, we describe
the setup and mechanics of running Selenium tests: managing a Selenium server and
integrating Selenium with JU nit 4.
12.7.1
Managing the Selenium server
To run Selenium tests, you must use the Selenium server included in the Selenium
Remote Control download.
Selenium: under the hood
The Selenium server launches the web browser and acts as a proxy server to your
tests; the server then runs the tests on your behalf. This architecture works for any
browser and operating system combination; you can also use it to test Ajax appli-
cations. This proxy server setup is why you may get certificate warnings.
To start the server manually, open a command-line window in the server directory, for
example: selenium-remote-control-1.0-beta-2\selenium-server-1.0-beta-2. Assuming the
JVM is on your PATH , type the following:
java -jar selenium-server.jar
You'll see, for example:
22:14:11.367 INFO - Java: Sun Microsystems Inc. 11.2-b01
22:14:11.382 INFO - OS: Windows XP 5.1 x86
22:14:11.382 INFO - v1.0-beta-2 [2571], with Core v1.0-beta-2 [2330]
22:14:11.539 INFO - Version Jetty/5.1.x
22:14:11.554 INFO - Started HttpContext[/selenium-server/driver,/
selenium-server/driver]
 
 
 
 
 
 
 
 
 
Search WWH ::




Custom Search