Go down
Posts : 1
Join date : 2012-11-19

Selenium webdriver Error - "Could not contact Selenium Server". Empty Selenium webdriver Error - "Could not contact Selenium Server".

on Mon Nov 19, 2012 4:48 pm

Here is simple webdriver program-

import org.openqa.selenium.WebDriver;
import org.openqa.selenium.firefox.FirefoxDriver;

public class First
public void testFirst() throws Exception
WebDriver driver = new FirefoxDriver();
driver.get("specific url");

Added JAR files are:
1. TestNG
2. selenium-server-standalone-2.25.0
3. selenium-java-2.25.0

Still i am getting following error:
java.lang.RuntimeException: Could not contact Selenium Server; have you started it on 'localhost:4444' ?

Please help.

Added comment - Script runs successfully when i start the selenium server

Last edited by mins.ghodake@gmail.com on Mon Nov 19, 2012 5:13 pm; edited 1 time in total (Reason for editing : Script runs successfully when i start the selenium server)
Posts : 387
Join date : 2009-07-30
Location : India

Selenium webdriver Error - "Could not contact Selenium Server". Empty Re: Selenium webdriver Error - "Could not contact Selenium Server".

on Mon Nov 19, 2012 8:43 pm

You may, or may not, need the Selenium Server, depending on how you intend to use Selenium-WebDriver. If you will be only using the WebDriver API you do not need the Selenium-Server.

may be your doing something wrong in code. try to execute the following code in fresh project and see whether it is working or not. don't start selenium server manually.


import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.openqa.selenium.support.ui.ExpectedCondition;
import org.openqa.selenium.support.ui.WebDriverWait;

public class Selenium2Example  {
    public static void main(String[] args) {
        // Create a new instance of the Firefox driver
        // Notice that the remainder of the code relies on the interface,
        // not the implementation.
        WebDriver driver = new FirefoxDriver();

        // And now use this to visit Google
        // Alternatively the same thing can be done like this
        // driver.navigate().to("http://www.google.com");

        // Find the text input element by its name
        WebElement element = driver.findElement(By.name("q"));

        // Enter something to search for

        // Now submit the form. WebDriver will find the form for us from the element

        // Check the title of the page
        System.out.println("Page title is: " + driver.getTitle());
        // Google's search is rendered dynamically with JavaScript.
        // Wait for the page to load, timeout after 10 seconds
        (new WebDriverWait(driver, 10)).until(new ExpectedCondition<Boolean>() {
            public Boolean apply(WebDriver d) {
                return d.getTitle().toLowerCase().startsWith("cheese!");

        // Should see: "cheese! - Google Search"
        System.out.println("Page title is: " + driver.getTitle());
        //Close the browser

[b]Note[/b]: if it still not working check all dependencies needed.
The easiest way to set up a Selenium 2.0 Java project is to use Maven. Maven will download the java bindings (the Selenium 2.0 java client library) and all its dependencies, and will create the project for you, using a maven pom.xml (project configuration) file. Once you’ve done this, you can import the maven project into your preferred IDE, IntelliJ IDEA or Eclipse.

For more details refer official doc.

Spread Your Knowledge About Selenium Tool.

Email: selenium.discussion.thread@live.com
Forum: http://seleniumforum.forumotion.net
Back to top
Permissions in this forum:
You cannot reply to topics in this forum