- mins.ghodake@gmail.com
- Posts : 1
Join date : 2012-11-19
Selenium webdriver Error - "Could not contact Selenium Server".
Mon Nov 19, 2012 4:48 pm
Hello,
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
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
Re: Selenium webdriver Error - "Could not contact Selenium Server".
Mon Nov 19, 2012 8:43 pm
Hi,
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.
[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.
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.
- Code:
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
driver.get("http://www.google.com");
// 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
element.sendKeys("Cheese!");
// Now submit the form. WebDriver will find the form for us from the element
element.submit();
// 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
driver.quit();
}
}
[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.
- Start Selenium RC server with cmd line option that never stop even it encounters error
- RESOLVED: Selenium Webdriver - SSL certificate error on IE8
- Can anyone help me to resolve the cache error in selenium webdriver?
- Selenium RC with NUnit throwing error - File does not exist. File 'c:\Projects\WebDriver\trunk\src\Selenium.Core\HttpCommandProcessor.cs'
- error set cookies on chromedriver this selenium-webdriver node js
Permissions in this forum:
You cannot reply to topics in this forum