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?