top of page

Exception in thread “main” org.openqa.selenium.WebDriverException: Error forwarding the

  • Writer: khyati sehgal
    khyati sehgal
  • Aug 26, 2014
  • 2 min read

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

  1. I started selenium server,both hub and node.

  2. java -jar selenium-server-standalone-2.41.0.jar -role hub -port 1111

  3. java -jar selenium-server-standalone-2.41.0.jar -role node -port 1111 -hub <hub-ip>:<hub-port>/grid/register

  4. 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
  1. Now, try running the above code snippet, you will get the ERROR mentioned above.

  2. Check the code carefully, we are trying to run your tests on the ‘Safari’ browser. But we have not added the capability so that selenium can take care of it. Let us do it:

  3. First, execute this command from the console prompt where your node is hosted.

java -jar selenium-server-standalone-2.42.2.jar -role node -hub http://&lt;hub-ip&gt;:&lt;hub-port&gt;/grid/register -port 5555 -browser browserName="&lt;code&gt;safari",&lt;/code&gt;version=5,platform=WINDOWS",javascriptEnable=true -Dwebdriver.ie.driver="F:\SafariDriver.exe
 
  1. Get this jar from here : https://code.google.com/p/selenium/downloads/detail?name=SafariDriver.safariextension-2.21.0.zip&can=1&q=

  2. Once you are done with this, now change your code like this:

  capabilities = new DesiredCapabilities();
 // Version of the browser
 capabilities.setVersion("versaoBrowser");
 capabilities.setBrowserName("safari");
 capabilities.setJavascriptEnabled(true);
 // Platform test runner
 capabilities.setPlatform(platform);
 
  1. 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 have to be fixed to resolve the above issue: 1. Check if you have a Safari browser at the server where you want to send your web driver’s execution. 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 standalone 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 an extra effort for doing so. And that extra stuff should be taken care of before the actual execution.

Will share more about selenium grid in my coming blogs 🙂

Opmerkingen


bottom of page