1

My browser invocation code is like:

else if(browserName.equals("chrome")) {
            System.setProperty("webdriver.chrome.driver", "/home/selenium-drivers/chromedriver");
            DesiredCapabilities capabilities = DesiredCapabilities.chrome();
            capabilities.setPlatform(Platform.LINUX);
            URL url_hub = new URL("http://my-remote-server-ip:4444/wd/hub");
            driver = new RemoteWebDriver(url_hub, capabilities);
            driver.manage().window().maximize();
            driver.get(url);
        }

Getting the following error while running the program :

Unable to create new remote session. desired capabilities = Capabilities [{browserName=chrome, version=, platform=WINDOWS}], required capabilities = Capabilities [{}] [grid -console]1

Sidhartha
  • 988
  • 4
  • 19
  • 39
  • Did you start the HUB & NODE with success? – undetected Selenium May 18 '17 at 07:41
  • @Dev yes .And I have got the console message "08:40:54.801 INFO - The node is registered to the hub and ready to use " – Sidhartha May 18 '17 at 08:42
  • Can you show me the commands how you started Hub & Node? Thanks – undetected Selenium May 18 '17 at 08:44
  • @Dev I am running the hub through Jenkins and the command I am using for node "java -jar selenium-server-standalone-3.4.0.jar -role node -hub http://my-server-ip:4444/grid/register " – Sidhartha May 18 '17 at 08:49
  • check the grid console if you see the node registered – metar May 18 '17 at 08:52
  • @metar I have attached the grid console screenshot.Please check and let men know what else information I need to provide . – Sidhartha May 18 '17 at 08:57
  • remove capabilities.setPlatform(Platform.WINDOWS); in your code and its fixed. you run the node on linux but you query the hub for a windows node – metar May 18 '17 at 09:42
  • @metar I have changed that in code ,now its working fine when I am running the program in local machine but still getting the same error while running the code on cloud. – Sidhartha May 18 '17 at 09:57
  • @Sidhartha you see chrome popping up on your local machine? If he uses a remote node you can easily see that in the grid - the icon is greyed out than – metar May 18 '17 at 10:01

1 Answers1

1

Here is the Answer of your Question:

Windows Platform

  1. Start the Selenium Grid Hub. Confirm the log message:

    14:25:50.350 INFO - Selenium Grid hub is up and running
    
  2. Open grid console URL (in my case http://localhost:4444/grid/console) and observe the console.

  3. Start the Selenium Grid Node & register it to the Hub:

    java -Dwebdriver.chrome.driver=C:\Utility\BrowserDrivers\chromedriver.exe -jar C:\Utility\selenium-server-standalone\selenium-server-standalone-3.4.0.jar -role node -hub http://localhost:4444/grid/register
    
  4. Look out for the Node Registration Logs:

    14:33:12.354 INFO - Selenium Grid node is up and ready to register to the hub
    14:33:12.409 INFO - Starting auto registration thread. Will try to register every 5000 ms.
    14:33:12.409 INFO - Registering the node to the hub: http://localhost:4444/grid/register
    14:33:12.756 INFO - The node is registered to the hub and ready to use
    
  5. Here is own working set of code twisted a bit to fit into my local Windows 8 box as localhost:4444 settings:

    System.setProperty("webdriver.chrome.driver", "C:\\Utility\\BrowserDrivers\\chromedriver.exe");
    DesiredCapabilities cap = DesiredCapabilities.chrome();
    cap.setBrowserName("chrome");
    cap.setPlatform(Platform.WINDOWS);
    URL url = new URL("http://localhost:4444/wd/hub");
    WebDriver driver = new RemoteWebDriver(url, cap);
    driver.get("http://google.com/");
    System.out.println("Title is : "+driver.getTitle());
    driver.quit();
    
  6. I get a result as:

    Title is : Google
    PASSED: test1
    
    ===============================================
    Default test
    Tests run: 1, Failures: 0, Skips: 0
    ===============================================
    

Let me know if this helps you.

undetected Selenium
  • 183,867
  • 41
  • 278
  • 352
  • I have followed all the above steps but getting "org.openqa.selenium.SessionNotCreatedException: Unable to create new remote session. desired capabilities = Capabilities [{browserName=chrome, version=, platform=WINDOWS}], required capabilities = Capabilities [{}] Build info: version: '3.0.1', revision: '1969d75', time: '2016-10-18 09:49:13 -0700' System info: host: 'arima-latitude-3460', ip: '127.0.1.1', os.name: 'Linux', os.arch: 'amd64', os.version: '3.13.0-117-generic', java.version: '1.8.0_131' Driver info: driver.version: RemoteWebDriver " this error. – Sidhartha May 18 '17 at 09:31
  • Your OS is Linux, so you have to make certain changes accordingly. 1.Path of `chromedriver` (linux type absolute path & without extension). 2. Change `Platform.WINDOWS` to `Platform.LINUX` 3. Pass exact IP & port instead of `http://localhost:4444/wd/hub` – undetected Selenium May 18 '17 at 09:36
  • I have changed that in code ,now its working fine when I am running the program in local machine but still getting the same error while running the code on cloud. – Sidhartha May 18 '17 at 09:58
  • Let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/144551/discussion-between-sidhartha-and-dev). – Sidhartha May 18 '17 at 11:04