Gbru
Gbru

Reputation: 1087

DesiredCapabilities 'Chrome' > doesn't work with 'Selenium Grid'

DesiredCapabilities 'Chrome' > doesn't work with 'Selenium Grid.

  1. I have a hub setup correctly and a node
  2. however when trying to point Chrome browser to one of the nodes it doesn't work.

Current code:

        case "chrome":
            if (null == webdriver) {
                System.setProperty("webdriver.chrome.driver", Constant.CHROME_DRIVER_DIRECTORY);
                DesiredCapabilities capability = DesiredCapabilities.chrome();
                capability.setBrowserName("chrome");
                capability.setVersion("55.0.2883.87 m");
                capability.setPlatform(Platform.WINDOWS);
                webdriver = new RemoteWebDriver(new URL("http://172.16.1.48:5555/wd/hub"),capability);

            }
            break;

Exception: org.openqa.selenium.SessionNotCreatedException: Unable to create new remote session. desired capabilities = Capabilities [{browserName=chrome, version=55.0.2883.87 m, platform=WINDOWS}], required capabilities = Capabilities [{}]

enter image description here

Upvotes: 0

Views: 2978

Answers (1)

Krishnan Mahadevan
Krishnan Mahadevan

Reputation: 14746

Couple of things :

  • On the node side, please ensure that the chromedriver (for chrome browser), geckodriver(for firefox browser) and IEDriverServer(for IE) are all available in the PATH variable and can be invoked by just opening up a command prompt and typing their names.
  • When you do DesiredCapabilities capability = DesiredCapabilities.chrome(); it automatically sets the browser name appropriately. So you don't need to set it again via capability.setBrowserName("chrome"); (So you can remove it off).
  • Unless and until you have explicitly set a browser version at your node level via the nodeConfig json file, please remove capability.setVersion("55.0.2883.87 m"); because this causes your test to ask for a node that can support chrome 55 version, but if you don't specify the same versioning at your node, your grid will turn down your new session request stating it cannot find the required desired capabilities.
  • Going by your screenshot it looks like your hub is running on localhost listening to the port 4444 but your code shows as if you are trying to connect to the node directly. So please change webdriver = new RemoteWebDriver(new URL("http://172.16.1.48:5555/wd/hub"),capability); to `webdriver = new RemoteWebDriver(new URL("http://localhost:4444/wd/hub"),capability);

Once you have taken care of these items, your issue should get fixed.

Upvotes: 0

Related Questions