1
votes

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

1
Did you start the HUB & NODE with success? - DebanjanB
@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
Can you show me the commands how you started Hub & Node? Thanks - DebanjanB
@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 " - Sidhartha
check the grid console if you see the node registered - metar

1 Answers

1
votes

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.