1

I am trying to run my Selenium C# automated test using Grid.
When i run the test I get the error:

Message: System.InvalidOperationException : Error forwarding the new session cannot find : Capabilities {browserName: chrome, marionette: false, platform: WINDOWS}

I have chromedriver.exe in the following directory:

F:\Selenium Projects\C#\Grid practice\automation\

I have set the path for Environment Variables from System, Control Panel to the path:

F:\Selenium Projects\C#\Grid practice\automation\

My code snippet is:

public class Browsers : DriverClass
{
    public IWebDriver LaunchBrowser(string browser)
    {
        switch (browser)
        {
            case "chrome":
                GoToChromeBrowser("chrome");
                break;

            case "firefox":
                GoToFirefoxBrowser();
                break;

            case "ie":
                GoToIeBrowser();
                break;

            case "edge":
                GoToEdgeBrowser();
                break;

            case "remote":
                GoToRemoteBrowser();
                break;
            default:
                throw new Exception("did not find browser type selected");
        }
        return Driver;
    }
}

The method GoToChromeBrowser():

public void GoToChromeBrowser(string BrowserType)
{
    switch (BrowserType)
    {
        case "firefox":
            Driver = new FirefoxDriver();
            break;
        case "chrome":
            DesiredCapabilities cap = new DesiredCapabilities();
            cap.SetCapability(CapabilityType.BrowserName, "chrome");
            cap.SetCapability("marionette", false);
            cap.SetCapability(CapabilityType.Platform, new Platform(PlatformType.Windows));
            Driver = new RemoteWebDriver(new Uri("http://localhost:4444/wd/hub"), cap);
            break;                    
    }
}

To start the Hub I use the command in CMD:

java -jar F:\Selenium\Server\selenium-server-standalone-3.11.0.jar -role hub

To register the node I use the command:

java -jar selenium-server-standalone-3.11.0.jar -role node -hub http://localhost:4444/grid/register -browser "browserName=chrome version=ANY, maxInstances=5, platform=WINDOWS" -port 5566 

The hub has started fine and the node is registered. No errors there.
Why am I getting the error when I run my test in Visual Studio?
What am i missing or doing wrong?

undetected Selenium
  • 183,867
  • 41
  • 278
  • 352
OptimusAutomation
  • 141
  • 1
  • 6
  • 15
  • Why have you got marionette driver set to false? If you're testing on Chrome you will be using Chromedriver, I would just remove it. Also, I presume your node is a Windows machine and has Chrome installed? – Simon N May 01 '18 at 01:43

2 Answers2

0

Try this. Specify the location of driver while starting your node.

java -Dwebdriver.chrome.driver=D:/nchaurasia/Automation-Architect/connect2tech.in-SeleniumWebDriver3.x_2/driver/chromedriver.exe -jar selenium-server-standalone-3.9.1.jar -role node -hub http://192.168.137.1:4444/grid/register/
Naresh Chaurasia
  • 419
  • 5
  • 21
  • That does not work for me. The node won't register to the hub with that command. Removing Dwebdriver.chrome.driver= the node registers fine. – OptimusAutomation May 01 '18 at 19:29
  • Can you tell what error you are getting. Make use you use -Dwebdriver.chrome.driver=. The - (hyphen) is important. It is used to pass argument to Java. – Naresh Chaurasia May 03 '18 at 03:02
  • The error I get is Error: Could not find or load main class Browsers\chromedriver.exe – OptimusAutomation May 07 '18 at 13:17
  • chromedriver.exe I have placed in my projects folder and I have also placed it in F:\Selenium Browsers\chromedriver.exe I have also set the path for the environment variable – OptimusAutomation May 07 '18 at 13:20
0

This error message...

selenium.common.exceptions.WebDriverException: Message: unknown error: Chrome failed to start: exited abnormally

...implies that the ChromeDriver was unable to initiate/spawn a new WebClient i.e. Chrome Browser session.

Your main issue is the presence of undefined capability for ChromeDriver as follows :

  • You have invoked SetCapability() with "marionette", false, but ChromeDriver doesn't supports any such capability as marionette.
  • The capability marionette is used by GeckoDriver and as you are using selenium-server-standalone-3.11.0.jar you have to mandatorily use GeckoDriver which by default sets marionette as true. If you forcefully set marionette as false, GeckoDriver will throw an exception.
  • As @NareshChaurasia pointed out while you initiate the Selenium Hub Node you have to pass the absolute path of the ChromeDriver as follows :

    java -Dwebdriver.chrome.driver=F:/Selenium Projects/C#/Grid practice/automation/chromedriver.exe -jar selenium-server-standalone-3.11.0.jar -role node -hub http://192.168.0.100:4444/grid/register
    
undetected Selenium
  • 183,867
  • 41
  • 278
  • 352