4

I am new to selenium.

This is what I did: I started a standalone selenium server on cmd prompt.

I ran below code, for both webDriverWay() and seleniumWay() I get error like below. In both cases I get

My test code:

static String baseUrl= "http:\\google.com" ;

public static void main(String[] args) throws MalformedURLException {

    //webDriverWay();
    seleniumWay();

}

private static void webDriverWay() throws MalformedURLException {
    URL url = new URL("http://127.0.0.1:4444/wd/hub"); //Could be your remote VM where you to run your tests

    DesiredCapabilities capabilities;
    capabilities = DesiredCapabilities.firefox();

    //You can test multiple type of browser
    //capabilities = DesiredCapabilities.internetExplorer();
    WebDriver driver = new RemoteWebDriver(url, capabilities);

    //Open the web site
    driver.get(baseUrl);

    //Type Search Term
    (driver.findElement(By.name("q"))).sendKeys("Test Search Query");

    //Click submit button
    (driver.findElement(By.name("btnG"))).click();
}


static void seleniumWay()
{
    Selenium sel = new DefaultSelenium("localhost", 4444, "*firefox", baseUrl);
    CommandExecutor executor = new SeleneseCommandExecutor(sel);
    DesiredCapabilities dc = new DesiredCapabilities();
    WebDriver browser = new RemoteWebDriver(executor, dc);

    browser.get(baseUrl);
    WebElement input = browser.findElement(By.name("q"));
    input.sendKeys("Selenium");
}

Exception in console:

Exception in thread "main" org.openqa.selenium.WebDriverException: Could not start Selenium session: org.openqa.grid.common.exception.GridException: Error forwarding the new session Empty pool of VM for setup {browserName=*safari}
Command duration or timeout: 61 milliseconds
Build info: version: '2.26.0', revision: '18040', time: '2012-11-02 09:44:45'
System info: os.name: 'Windows 8', os.arch: 'amd64', os.version: '6.2', java.version: '1.7.0_09'
Driver info: driver.version: RemoteWebDriver
    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57)
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
    at java.lang.reflect.Constructor.newInstance(Constructor.java:525)
    at org.openqa.selenium.remote.ErrorHandler.createThrowable(ErrorHandler.java:188)
    at org.openqa.selenium.remote.ErrorHandler.throwIfResponseFailed(ErrorHandler.java:145)
    at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:531)
    at org.openqa.selenium.remote.RemoteWebDriver.startSession(RemoteWebDriver.java:215)
    at org.openqa.selenium.remote.RemoteWebDriver.<init>(RemoteWebDriver.java:110)
    at org.openqa.selenium.remote.RemoteWebDriver.<init>(RemoteWebDriver.java:114)

Please let me know if I am missing something.

1
  • 1
    This error usually happens when you start an execution grid but don't have any nodes associated with it. Have you installed Selenium Server and registered your remote WebDriver to it? Commented May 21, 2013 at 18:35

1 Answer 1

2

This guide has all the information you need to configure your tests. I had a very similar issue when I first started using Selenium myself.

Sign up to request clarification or add additional context in comments.

1 Comment

Same here! Thanks for this answer and link (although I am using Selenium/C#), +1.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.