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

9
  • Did you start the HUB & NODE with success? Commented May 18, 2017 at 7: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 " Commented May 18, 2017 at 8:42
  • Can you show me the commands how you started Hub & Node? Thanks Commented May 18, 2017 at 8: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 my-server-ip:4444/grid/register " Commented May 18, 2017 at 8:49
  • check the grid console if you see the node registered Commented May 18, 2017 at 8:52

1 Answer 1

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.

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

4 Comments

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

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.