Connection refused error for WebDriver

1,482 views
Skip to first unread message

John

unread,
Sep 2, 2011, 8:52:10 PM9/2/11
to Selenium Users
Hi All,

I am trying to learn how to use the WebDriver (Selenium 2.0) for Java
API (version 2.5.0). I am using TestNG 5.14.2 for my testing
framework. I am running the test in Eclipse Indigo. I use Maven to
generate my project dependencies.

I have been unable to get a test to run as I keep getting a error:
"com.thoughtworks.selenium.SeleniumException: Connection refused:
connect".

I looked at https://groups.google.com/group/selenium-users/browse_thread/thread/88ca9a43b5ae1c7f/1917ffdf036335b6
and updated my pom.xml to only include the "selenium-server"
dependency, but all of the other selenium jar files seem to have been
pulled in as transitive dependencies.

The following test method demonstrates my problem:

@Test
public void testGoogle() throws Exception {
WebDriver driver = new FirefoxDriver();
driver.get("http://www.google.com");
WebElement element = driver.findElement(By.name("q"));
element.sendKeys("Cheese!");
element.submit();
driver.quit();
}

When I run this, I get this in the console:
RemoteTestNG starting
com.thoughtworks.selenium.SeleniumException: Connection refused:
connect
at
com.thoughtworks.selenium.HttpCommandProcessor.executeCommandOnServlet(HttpCommandProcessor.java:
111)
at
com.thoughtworks.selenium.HttpCommandProcessor.doCommand(HttpCommandProcessor.java:
90)
at
com.thoughtworks.selenium.DefaultSelenium.captureScreenshot(DefaultSelenium.java:
719)
at
com.thoughtworks.selenium.ScreenshotListener.onTestFailure(ScreenshotListener.java:
27)
at
com.thoughtworks.selenium.ScreenshotListener.onConfigurationFailure(ScreenshotListener.java:
41)
at org.testng.internal.Invoker.runConfigurationListeners(Invoker.java:
1791)
at
org.testng.internal.Invoker.handleConfigurationFailure(Invoker.java:
323)
at org.testng.internal.Invoker.invokeConfigurations(Invoker.java:226)
at org.testng.internal.Invoker.invokeConfigurations(Invoker.java:130)
at org.testng.TestRunner.beforeRun(TestRunner.java:632)
at org.testng.TestRunner.run(TestRunner.java:600)
at org.testng.SuiteRunner.runTest(SuiteRunner.java:334)
at org.testng.SuiteRunner.runSequentially(SuiteRunner.java:329)
at org.testng.SuiteRunner.privateRun(SuiteRunner.java:291)
at org.testng.SuiteRunner.run(SuiteRunner.java:240)
at org.testng.SuiteRunnerWorker.runSuite(SuiteRunnerWorker.java:52)
at org.testng.SuiteRunnerWorker.run(SuiteRunnerWorker.java:86)
at org.testng.TestNG.runSuitesSequentially(TestNG.java:1158)
at org.testng.TestNG.runSuitesLocally(TestNG.java:1083)
at org.testng.TestNG.run(TestNG.java:999)
at org.testng.remote.RemoteTestNG.run(RemoteTestNG.java:111)
at org.testng.remote.RemoteTestNG.initAndRun(RemoteTestNG.java:203)
at org.testng.remote.RemoteTestNG.main(RemoteTestNG.java:174)
Caused by: java.net.ConnectException: Connection refused: connect
at java.net.PlainSocketImpl.socketConnect(Native Method)
at java.net.PlainSocketImpl.doConnect(Unknown Source)
at java.net.PlainSocketImpl.connectToAddress(Unknown Source)
at java.net.PlainSocketImpl.connect(Unknown Source)
at java.net.SocksSocketImpl.connect(Unknown Source)
at java.net.Socket.connect(Unknown Source)
at java.net.Socket.connect(Unknown Source)
at sun.net.NetworkClient.doConnect(Unknown Source)
at sun.net.www.http.HttpClient.openServer(Unknown Source)
at sun.net.www.http.HttpClient.openServer(Unknown Source)
at sun.net.www.http.HttpClient.<init>(Unknown Source)
at sun.net.www.http.HttpClient.New(Unknown Source)
at sun.net.www.http.HttpClient.New(Unknown Source)
at
sun.net.www.protocol.http.HttpURLConnection.getNewHttpClient(Unknown
Source)
at sun.net.www.protocol.http.HttpURLConnection.plainConnect(Unknown
Source)
at sun.net.www.protocol.http.HttpURLConnection.connect(Unknown
Source)
at
sun.net.www.protocol.http.HttpURLConnection.getOutputStream(Unknown
Source)
at
com.thoughtworks.selenium.HttpCommandProcessor.getOutputStreamWriter(HttpCommandProcessor.java:
138)
at
com.thoughtworks.selenium.HttpCommandProcessor.getCommandResponseAsString(HttpCommandProcessor.java:
165)
at
com.thoughtworks.selenium.HttpCommandProcessor.executeCommandOnServlet(HttpCommandProcessor.java:
108)
... 22 more

Going on the comments in that other thread, I might need to remove
some of the dependencies, but I just don't know which ones.

I have the following dependencies (among many others) in my project
after running "mvn eclipse:clean eclipse:eclipse":
selenium-api-2.5.0.jar
selenium-chrome-driver-2.5.0.jar
selenium-firefox-driver-2.5.0.jar
selenium-htmlunit-driver-2.5.0.jar
selenium-ie-driver-2.5.0.jar
selenium-iphone-driver-2.5.0.jar
selenium-java-2.5.0.jar
selenium-remote-driver-2.5.0.jar
selenium-server-2.5.0.jar
selenium-support-2.5.0.jar

All of those were pulled in from the following entry in my pom.xml
file:
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-server</artifactId>
<version>2.5.0</version>
</dependency>

Any help is very much appreciated.

Thanks,
John

Paul Hammant

unread,
Sep 3, 2011, 5:48:50 AM9/3/11
to seleniu...@googlegroups.com
This looks weird to me:  Selenium 1.x exceptions and stack traces for Selenium 2.x interactions.


--
You received this message because you are subscribed to the Google Groups "Selenium Users" group.
To post to this group, send email to seleniu...@googlegroups.com.
To unsubscribe from this group, send email to selenium-user...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/selenium-users?hl=en.


John

unread,
Sep 3, 2011, 2:16:31 PM9/3/11
to Selenium Users
That's a clue. This project might have legacy inclusions from a few
years ago. I'll check that out. Thanks!

On Sep 3, 2:48 am, Paul Hammant <p...@hammant.org> wrote:
> This looks weird to me:  Selenium 1.x exceptions and stack traces for
> Selenium 2.x interactions.
>
>
>
> On Fri, Sep 2, 2011 at 7:52 PM, John <johnfr...@gmail.com> wrote:
> > Hi All,
>
> > I am trying to learn how to use the WebDriver (Selenium 2.0) for Java
> > API (version 2.5.0).  I am using TestNG 5.14.2 for my testing
> > framework.  I am running the test in Eclipse Indigo.  I use Maven to
> > generate my project dependencies.
>
> > I have been unable to get a test to run as I keep getting a error:
> > "com.thoughtworks.selenium.SeleniumException: Connection refused:
> > connect".
>
> > I looked at
> >https://groups.google.com/group/selenium-users/browse_thread/thread/8...

John

unread,
Sep 3, 2011, 4:25:12 PM9/3/11
to Selenium Users
Paul, your clue helped me solve the problem. I had originally
generated the test using export from Selenium IDE. Obviously, I had
edited every line of that to get it in line with Selenium 2.0.
Unfortunately, the "extends SeleneseTestNGHelper" was still there.
The problem was a @BeforeTest method from that Selenium 1.0 class.
Reply all
Reply to author
Forward
Message has been deleted
0 new messages