9 Important Tips for Selenium Remote Control (Java client) - Test Tool

By Angsuman Chakraborty, Gaea News Network
Wednesday, April 16, 2008

Selenium Remote Control (RC) is a test tool that allows you to write automated web application UI tests in many programming languages against any HTTP website using any mainstream JavaScript-enabled browser. Selenium RC is a powerful and simple framework for running (scheduled or manually) automated UI centric regression tests for web applications / services. Here are few simple tips for Selenium RC java client. I used JUnit for tests. You can use NGUnit too.

1. To run the Java client you need to only have selenium-java-client-driver.jar (located in selenium-remote-control-1.0-beta-1/selenium-java-client-driver-1.0-beta-1 ) in your classpath.

2. The automatically generated java file (from Selenium Core) is likely to be defective. Ensure at least you have the following import statements:

import com.thoughtworks.selenium.*;
import junit.framework.*;
import java.util.regex.Pattern;

3. Ensure that the saved file name matches the generated class file name.

4. Remove the package statement or replace it with your own package statement. Initially just remove it.

5. Error: java.lang.UnsupportedOperationException: Catch body broken: IOException from cmd=setContext&1=SeleniumSTSanityTest.testSimpleThoughts -> java.net.ConnectException: Connection refused

Have you run the Selenium server?
Run the Selenium server like this:
java -jar selenium-server.jar

The selenium server is located in:

6. Error: com.thoughtworks.selenium.SeleniumException: ERROR Server Exception: sessionId should not be null; has this session been started yet?

Ensure that the browser is in the PATH before running the server. On my linux box I did:
export PATH=$PATH:/usr/lib/firefox-

7. Error: com.thoughtworks.selenium.SeleniumException: Permission denied to get property Location.href

This happens on Firefox when a previous page wasn’t fully loaded before the next page was invoked (due to timeout or click() was used). The solution is to use *chrome instead of *firefox in setup. I use for firefox:
setUp(”https://blog.taragana.com/”, “*chrome”);

8. Timeout error
Increase the time in selenium.waitForPageToLoad() to 60000 (1 minute) or more.

9. How to run the generated java Test file?
This is really a JUnit question but in short you can add the following code in the generated file to get it running:

public static Test suite() {
	return new TestSuite(SeleniumSTSanityTest.class);

public static void main(String args[]) {

Note: Replace SeleniumSTSanityTest with the name of your Java source file (without the .java extension)


September 15, 2010: 4:27 am

My java file name is newtest and received this run time error.Please reply as soon as possible.

Time: 0
There was 1 failure:
1) warning(junit.framework.TestSuite$1)j
tests found in newtest
at newtest.main(newtest.java:27)

Tests run: 1, Failures: 1, Errors: 0

Sunil Kadur
June 30, 2010: 2:16 am


Currently I am using Selenium RC.

Can anybody help me out for “How to Run Selenium RC Scripts (generated
in Java) in different browsers one after the other. i.e After
executing the scripts in one browser(Firefox), need to run the same
scripts in the other browser(IE) using Eclipse.

Thanks in advance.
- Sunil D

May 20, 2010: 4:35 am

com.thoughtworks.selenium.SeleniumException: Connection refused

this is the error I get, hope for your help in solving this one.

May 19, 2010: 1:17 am

i wrote a simple selenium test case which goes like this….

package com.testscripts;

import com.thoughtworks.selenium.*;
import junit.framework.*;
//import java.util.regex.Pattern;

public class first extends SeleneseTestCase {
public void setUp() throws Exception {
setUp(”https://www.google.co.in/”, “*chrome”);
public void testFirst() throws Exception {
selenium.type(”q”, “god is an astronaut”);
assertTrue(”text not found”,selenium.isTextPresent(”Astronaut”));
private static Test suite() {
return new TestSuite(first.class);

public static void main(String args[]) {


when i complie it i get an error saying junit.framework does not exist….doesnt recognise TestCase class too…..pls help asap..

March 22, 2010: 8:28 am

Superb. :)

I was able to run the program without any exceptions.

Sunil Gupta
August 25, 2009: 6:20 am

Can you please send me details that doc. from biggener to expert that how to full concept of selenium automation tools from starting.

July 29, 2009: 10:47 am

Suresh Kanukonala, use Maven or Ant

March 18, 2009: 12:55 am

I have a problem when I try to run the generated java code thru Eclipse. When I run the same code in debug mode thru Eclipse as JUnit test case, it runs perfectly well (I step over each statement), but If I run it normally i.e, not in debug mode, the initial screen loads and 1 or 2 steps are performed and then the flow stops and after a while the test case fails. What could be the posiible reason for this.
Can anyone help me with this

Suresh Kanukonala
February 14, 2009: 12:15 pm

I have 10 tests in the same project..Say Test1, Test2, …Test10.
Now can i make those test rum at a time? i mean how can i put all these tests in the test suite.!
please help me..

Thanks in Advance.

February 3, 2009: 10:26 pm

How do you stop the server?

January 8, 2009: 11:39 pm

Hi, i am getting the following complilation error while executing

[Kamakshi@localhost seleniumrc]$ javac myseleniumtest.java
myseleniumtest.java:3: package com.thoughtworks.selenium does not exist
import com.thoughtworks.selenium.*;
myseleniumtest.java:6: cannot find symbol
symbol: class SeleneseTestCase
public class myseleniumtest extends SeleneseTestCase {
myseleniumtest.java:8: setUp() in com.example.tests.myseleniumtest cannot be applied to (java.lang.String,java.lang.String)
setUp(”https://change-this-to-the-site-you-are-testing/”, “*chrome”);
myseleniumtest.java:11: cannot find symbol
symbol : variable selenium
location: class com.example.tests.myseleniumtest
myseleniumtest.java:12: cannot find symbol
symbol : variable selenium
location: class com.example.tests.myseleniumtest
selenium.type(”q”, “birds”);
myseleniumtest.java:13: cannot find symbol
symbol : variable selenium
location: class com.example.tests.myseleniumtest
myseleniumtest.java:14: cannot find symbol
symbol : variable selenium
location: class com.example.tests.myseleniumtest
7 errors
For the following

package com.example.tests;

import com.thoughtworks.selenium.*;
import java.util.regex.Pattern;

public class myseleniumtest extends SeleneseTestCase {

public void setUp() throws Exception {
setUp(”https://change-this-to-the-site-you-are-testing/”, “*chrome”);
public void testNew() throws Exception {
selenium.type(”q”, “birds”);


shital mukhedkar
January 8, 2009: 6:23 am

I’m getting this error when my test runs successfully, but displays errors as:
junit.framework.AssertionFailedError: Expected “” but saw “junit.framework.AssertionFailedError: null” instead
at junit.framework.Assert.fail(Assert.java:47)
at junit.framework.Assert.assertTrue(Assert.java:20)
at com.thoughtworks.selenium.SeleneseTestCase.assertEquals(SeleneseTestCase.java:207)
at com.thoughtworks.selenium.SeleneseTestCase.checkForVerificationErrors(SeleneseTestCase.java:381)
at com.thoughtworks.selenium.SeleneseTestCase.tearDown(SeleneseTestCase.java:393)
at junit.framework.TestCase.runBare(TestCase.java:140)
at com.thoughtworks.selenium.SeleneseTestCase.runBare(SeleneseTestCase.java:71)
at junit.framework.TestResult$1.protect(TestResult.java:110)
at junit.framework.TestResult.runProtected(TestResult.java:128)
at junit.framework.TestResult.run(TestResult.java:113)
at junit.framework.TestCase.run(TestCase.java:124)
at junit.framework.TestSuite.runTest(TestSuite.java:232)
at junit.framework.TestSuite.run(TestSuite.java:227)
at org.junit.internal.runners.JUnit38ClassRunner.run(JUnit38ClassRunner.java:79)
at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:38)
at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:460)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:673)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:386)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:196)

October 2, 2008: 1:21 am

I’m getting the following error when I run selenium,
java.lang.UnsupportedOperationException: Catch body broken: IOException from cmd=setTimeout&1=120000 -> java.net.ConnectException: Connection refused

any help on this will be greatly appreciated.
thanks a lot.


active decay
May 23, 2008: 11:28 am

You have made my life a joy.

will not be displayed