0

I have been using [webdriver manager][1] for local executions, it has been outstanding, however right now I'm trying to use a selenium grid and I would like to use the same approach but I'm getting some errors related to capabilities.

The hub and node are localhost, these are the details of my implementation:

I'm starting the hub with this line:

    start cmd /k java -jar selenium-server-standalone-3.5.0.jar -role hub -port 4443

I'm starting the node with this line

    start cmd /k java -jar selenium-server-standalone-3.5.0.jar -port 5556 -role node -hub http://localhost:4443/grid/register 

This is the configuration that I'm using for the browsers, the problem is with chrome, I haven't tested the other ones yet.

public WebDriver cbt(String browser,  String methodName) throws Exception{
        WebDriver driver;
        DesiredCapabilities caps;

        //Check if parameter passed from TestNG is 'firefox'
        if(browser.equalsIgnoreCase("firefox"))
        {
            caps = DesiredCapabilities.firefox();
            caps.setCapability("platform", "Windows 10");
            caps.setCapability("version", "53.0");
            caps.setCapability("name", methodName);

        }

        //Check if parameter passed as 'chrome'

        else if(browser.equalsIgnoreCase("chrome"))
        {
             caps = DesiredCapabilities.chrome();

        }

        else if(browser.equalsIgnoreCase("ie")){

            caps = DesiredCapabilities.edge();
            caps.setCapability("platform", "Windows 10");
            caps.setCapability("version", "14.14393");
            caps.setCapability("name", methodName);


        }

        else{

            //If no browser passed throw exception

            throw new Exception("Browser is not correct");

        }
        String hub = "http://localhost:4443/wd/hub";
        driver = new RemoteWebDriver(new URL(hub), caps);
        return driver;
    }

These are the errors that I'm getting

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

    Build info: version: '3.3.1', revision: '5234b325d5', time: '2017-03-10 09:10:29 +0000'
    System info: host: 'NEYMAR', ip: '169.254.112.118', os.name: 'Windows 8.1', os.arch: 'amd64', os.version: '6.3', java.version: '1.8.0_45'
    Driver info: driver.version: RemoteWebDriver
        at org.openqa.selenium.remote.ProtocolHandshake.createSession(ProtocolHandshake.java:126)
        at org.openqa.selenium.remote.HttpCommandExecutor.execute(HttpCommandExecutor.java:141)
        at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:604)
        at org.openqa.selenium.remote.RemoteWebDriver.startSession(RemoteWebDriver.java:244)
        at org.openqa.selenium.remote.RemoteWebDriver.<init>(RemoteWebDriver.java:131)
        at org.openqa.selenium.remote.RemoteWebDriver.<init>(RemoteWebDriver.java:158)
        at com.gnow.gnow.Utils.CommonConfiguration.cbt(CommonConfiguration.java:213)
        at com.gnow.gnow.Test.Test.setUp(Test.java:69)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
        at java.lang.reflect.Method.invoke(Unknown Source)
        at org.testng.internal.MethodInvocationHelper.invokeMethod(MethodInvocationHelper.java:104)
        at org.testng.internal.Invoker.invokeConfigurationMethod(Invoker.java:515)
        at org.testng.internal.Invoker.invokeConfigurations(Invoker.java:217)
        at org.testng.internal.Invoker.invokeMethod(Invoker.java:590)
        at org.testng.internal.Invoker.invokeTestMethod(Invoker.java:851)
        at org.testng.internal.Invoker.invokeTestMethods(Invoker.java:1177)
        at org.testng.internal.TestMethodWorker.invokeTestMethods(TestMethodWorker.java:129)
        at org.testng.internal.TestMethodWorker.run(TestMethodWorker.java:112)
        at org.testng.TestRunner.privateRun(TestRunner.java:756)
        at org.testng.TestRunner.run(TestRunner.java:610)
        at org.testng.SuiteRunner.runTest(SuiteRunner.java:387)
        at org.testng.SuiteRunner.runSequentially(SuiteRunner.java:382)
        at org.testng.SuiteRunner.privateRun(SuiteRunner.java:340)
        at org.testng.SuiteRunner.run(SuiteRunner.java:289)
        at org.testng.SuiteRunnerWorker.runSuite(SuiteRunnerWorker.java:52)
        at org.testng.SuiteRunnerWorker.run(SuiteRunnerWorker.java:86)
        at org.testng.TestNG.runSuitesSequentially(TestNG.java:1293)
        at org.testng.TestNG.runSuitesLocally(TestNG.java:1218)
        at org.testng.TestNG.runSuites(TestNG.java:1133)
        at org.testng.TestNG.run(TestNG.java:1104)
        at org.testng.remote.AbstractRemoteTestNG.run(AbstractRemoteTestNG.java:132)
        at org.testng.remote.RemoteTestNG.initAndRun(RemoteTestNG.java:230)
        at org.testng.remote.RemoteTestNG.main(RemoteTestNG.java:76)

Thanks in advance

  [1]: https://github.com/bonigarcia/webdrivermanager
axcha15
  • 53
  • 9

1 Answers1

2

First thing i would suggest is that you upgrade your selenium version to Selenium 3.5.1

There was a bug in Selenium 3.3.1 wherein the actual error wouldn't be passed on to the end-user, and your stacktrace seems to suggest that it's perhaps due to that bug is why you aren't able to see the real problem. This bug was fixed in 3.4.0

Once you upgrade to Selenium 3.5.1 in your client side, you should immediately see the problem.

Since you mentioned Chrome, am guessing that it is perhaps due to the fact that your chromedriver is not available in the PATH.

You might want to take a look at this tutorial I wrote up on Grid, which tells you the set of things that is required to get the Grid up and running. I have included a lot of other information about the Grid as well in there.

Krishnan Mahadevan
  • 14,121
  • 6
  • 34
  • 66
  • You were right,thanks! I updated that version and then I got another error, I will check it org.openqa.selenium.WebDriverException: Unable to parse remote response: Error 500 Server Error

    HTTP ERROR 500

    Problem accessing /wd/hub/session. Reason:

        Server Error

    Caused by:

    java.lang.NullPointerException
    – axcha15 Aug 18 '17 at 15:22
  • @axcha15 - If my answer helped you, can you please help accept it ? For your error, you might want to search through SO first and if you dont find it asked already, you can create a new question. – Krishnan Mahadevan Aug 18 '17 at 15:23
  • @KrishnanMahadevan I went through [this](https://rationaleemotions.github.io/gridopadesham/GETTING_STARTED.html#journey) article of yours and got to learn a lot. I have a query though. Is there a way we can use WebDriverManager to automatically configure the Browser Driver binaries when we are using SeleniumGrid? – Gurmanjot Singh Aug 01 '20 at 03:30
  • 1
    @Potatoツ no you cannot do that. WebDriverManager works on the client side, and not on the remote machine's side (which is true in the case of Grid) – Krishnan Mahadevan Aug 03 '20 at 14:57
  • @KrishnanMahadevan regarding your statement, "WebDriverManager works on the client side, and not on the remote machine's side" is this still true? I'm currently starting down the path of learning WDM specifically for use in Selenium Grid. Perhaps support for grid is only part of WDM 5.0 per https://github.com/bonigarcia/webdrivermanager/blob/master/CHANGELOG.md – Steven Erat Jan 06 '22 at 18:06