eclipse, Exception, Java, Selenium, Selenium Errors, Testing, Web Automation, Web Testing

Exception in thread “main” org.openqa.selenium.WebDriverException: Error forwarding the new session Empty pool of VM for setup Capabilities [{browserName=safari}]

ERROR

Exception in thread "main" org.openqa.selenium.WebDriverException: Error forwarding the new session Empty pool of VM for setup Capabilities [{browserName=safari}]
Command duration or timeout: 198 milliseconds
Build info: version: '2.41.0', revision: '3192d8a', time: '2014-03-27 17:17:32'
System info: host: 'ksehgal', ip: '192.168.14.1', os.name: 'Windows 7', os.arch: 'amd64', os.version: '6.1', java.version: '1.7.0_67'
Driver info: org.openqa.selenium.remote.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:526)
at org.openqa.selenium.remote.ErrorHandler.createThrowable(ErrorHandler.java:193)
at org.openqa.selenium.remote.ErrorHandler.throwIfResponseFailed(ErrorHandler.java:145)
at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:595)
at org.openqa.selenium.remote.RemoteWebDriver.startSession(RemoteWebDriver.java:240)
at org.openqa.selenium.remote.RemoteWebDriver.<init>(RemoteWebDriver.java:126)
at org.openqa.selenium.remote.RemoteWebDriver.<init>(RemoteWebDriver.java:153)
at remoteDriver.TestFireFoxRemotely.main(TestFireFoxRemotely.java:17)


And some more stack trace

Caused by: org.openqa.grid.common.exception.GridException: Error forwarding the new session Empty pool of VM for setup Capabilities [{browserName=safari}]
at org.openqa.grid.web.servlet.handler.RequestHandler.process(RequestHandler.java:114)
at org.openqa.grid.web.servlet.DriverServlet.process(DriverServlet.java:83)
at org.openqa.grid.web.servlet.DriverServlet.doPost(DriverServlet.java:67)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:727)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:820)
at org.seleniumhq.jetty7.servlet.ServletHolder.handle(ServletHolder.java:565)
at org.seleniumhq.jetty7.servlet.ServletHandler.doHandle(ServletHandler.java:479)
at org.seleniumhq.jetty7.server.session.SessionHandler.doHandle(SessionHandler.java:225)
at org.seleniumhq.jetty7.server.handler.ContextHandler.doHandle(ContextHandler.java:1031)
at org.seleniumhq.jetty7.servlet.ServletHandler.doScope(ServletHandler.java:406)
at org.seleniumhq.jetty7.server.session.SessionHandler.doScope(SessionHandler.java:186)
at org.seleniumhq.jetty7.server.handler.ContextHandler.doScope(ContextHandler.java:965)
at org.seleniumhq.jetty7.server.handler.ScopedHandler.handle(ScopedHandler.java:117)
at org.seleniumhq.jetty7.server.handler.HandlerWrapper.handle(HandlerWrapper.java:111)
at org.seleniumhq.jetty7.server.Server.handle(Server.java:349)
at org.seleniumhq.jetty7.server.AbstractHttpConnection.handleRequest(AbstractHttpConnection.java:452)
at org.seleniumhq.jetty7.server.BlockingHttpConnection.handleRequest(BlockingHttpConnection.java:47)
at org.seleniumhq.jetty7.server.AbstractHttpConnection.content(AbstractHttpConnection.java:894)
at org.seleniumhq.jetty7.server.AbstractHttpConnection$RequestHandler.content(AbstractHttpConnection.java:948)
at org.seleniumhq.jetty7.http.HttpParser.parseNext(HttpParser.java:857)
at org.seleniumhq.jetty7.http.HttpParser.parseAvailable(HttpParser.java:235)
at org.seleniumhq.jetty7.server.BlockingHttpConnection.handle(BlockingHttpConnection.java:66)
at org.seleniumhq.jetty7.server.bio.SocketConnector$ConnectorEndPoint.run(SocketConnector.java:254)
at org.seleniumhq.jetty7.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:599)
at org.seleniumhq.jetty7.util.thread.QueuedThreadPool$3.run(QueuedThreadPool.java:534)
at java.lang.Thread.run(Thread.java:745)

Code Snippet Used

public static void main(String [] args){
DesiredCapabilities capabilities = new DesiredCapabilities();
capabilities.setBrowserName("safari");
RemoteWebDriver remoteWD = null;
try{
remoteWD = new RemoteWebDriver(new URL("http://127.0.0.1:4444/wd/hub"),capabilities);
}catch(MalformedURLException e){
e.printStackTrace();
}
remoteWD.get("http://google.com");
remoteWD.findElement(By.name("q")).sendKeys("Testing");
}
}

How I stumble upon the above error

  • I started selenium server,both hub and node.
  1. java -jar selenium-server-standalone-2.41.0.jar -role hub -port 1111
  2. java -jar selenium-server-standalone-2.41.0.jar -role node -port 1111 -hub <hub-ip>:<hub-port>/grid/register
  • So now you have server and node in selenium grid set up which is running in default mode i.e. 5 browser instance of Chrome, 5 browser instance of FireFox, 1 browser instance of IE.
    DefaultSeleniumGridConsole
  • Now, try running the above code snippet, you will get the ERROR mentioned above.
  • Check the code carefully, we are trying to run your tests on ‘Safari’ browser. But we have not added the capability so that selenium can take care of it. Let us do it:
  • First execute this command from console prompt where your node is hosted.
java -jar selenium-server-standalone-2.42.2.jar -role node -hub http://<hub-ip>:<hub-port>/grid/register -port 5555 -browser browserName="<code>safari",</code>version=5,platform=WINDOWS",javascriptEnable=true -Dwebdriver.ie.driver="F:\SafariDriver.exe
  capabilities = new DesiredCapabilities();
 // Version of the browser
 capabilities.setVersion("versaoBrowser");
 capabilities.setBrowserName("safari");
 capabilities.setJavascriptEnabled(true);
 // Platform test runner
 capabilities.setPlatform(platform);
  • And try running your tests again. This should fix the error which was coming earlier.

Root Cause Analysis

The problem was more of the browser. There could be possible below areas which has to be fixed to resolve the above issue:
1. Check if you have Safari browser at the server where you want to send your webdriver execution to. This could be your local machine or remote virtual box,etc
2. Check if you have possible drivers , required for execution.
3. Check if valid-compatible safari browser compatible jar of selenium stand alone jar at the desired machine.

For me its the first issue, at the remote machine safari browser was not there , I picked the latest safari browser along with the latest selenium standalone jar. And this worked for me.
Conclusion

If  you want your tests on any environment other than default then you need to make extra effort for doing so. And that extra stuff should be taken care before the actual execution.

Will share more about selenium grid in my coming blogs 🙂

Advertisements

1 thought on “Exception in thread “main” org.openqa.selenium.WebDriverException: Error forwarding the new session Empty pool of VM for setup Capabilities [{browserName=safari}]”

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s