Why am I getting a GridException when I try to open a website using Selenium

I am new to selenium.

Here's what I did: I started the standalone selenium server on the cmd command line.

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

My test code is:

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"); } 

Console exception:

 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 missed something.

+4
source share
1 answer

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

+2
source

Source: https://habr.com/ru/post/1482016/


All Articles