I have a sample UI test project using v3.4.0 of Selenium.WebDriver.
Everything works fine when I run the tests against a local driver but I want to get things working using Selenium Grid 2.
As soon as I try to instantiate a new RemoteWebDriver I get an exception with little detail.
Driver = new RemoteWebDriver(new Uri(GridUrl), Capabilities);
Note: GridUrl is "http://localhost:4444/wd/hub"
Throws a System.InvalidOperationException with StackTrace as follows:
at OpenQA.Selenium.Remote.RemoteWebDriver.UnpackAndThrowOnError(Response errorResponse)
at OpenQA.Selenium.Remote.RemoteWebDriver.Execute(String driverCommandToExecute, Dictionary`2 parameters)
at OpenQA.Selenium.Remote.RemoteWebDriver.StartSession(ICapabilities desiredCapabilities)
at OpenQA.Selenium.Remote.RemoteWebDriver..ctor(ICommandExecutor commandExecutor, ICapabilities desiredCapabilities)
at OpenQA.Selenium.Remote.RemoteWebDriver..ctor(Uri remoteAddress, ICapabilities desiredCapabilities)
at xxxx.Ui.Tests.SeleniumTests.TestInitialize() in C:\Users\xxxx\Documents\Visual Studio 2015\Projects\xxxx.Ui.Tests\xxxx.Tests\PersonTests.cs:line 38
I have v3.4.0 of the hub running locally with the following configuration:
{
"port": 4444,
"newSessionWaitTimeout": -1,
"servlets" : [],
"withoutServlets": [],
"custom": {},
"capabilityMatcher":"org.openqa.grid.internal.utils.DefaultCapabilityMatcher",
"throwOnCapabilityNotPresent": true,
"cleanUpCycle": 5000,
"role": "hub",
"debug": false,
"browserTimeout": 0,
"timeout": 1800
}
Hub started with:
java -jar selenium-server-standalone-3.4.0.jar -role hub
This has come up OK and looks to be running.
I have tried a number of nodes (chromedriver.exe, IEDriverServer.exe and geckodrvier.exe). None of these work with the RemoteWebDriver. All of them are in a directory that has been added to my system PATH variable.
{
"capabilities":
[
{
"browserName": "chrome",
"maxInstances": 5,
"seleniumProtocol": "WebDriver"
}
],
"proxy": "org.openqa.grid.selenium.proxy.DefaultRemoteProxy",
"maxSession": 5,
"port": 5556,
"register": true,
"registerCycle": 5000,
"hub": "http://localhost:4444",
"nodeStatusCheckTimeout": 5000,
"nodePolling": 5000,
"role": "node",
"unregisterIfStillDownAfter": 60000,
"downPollingLimit": 2,
"debug": false,
"servlets" : [],
"withoutServlets": [],
"custom": {}
}
Node started with:
java -jar selenium-server-standalone-3.4.0.jar -role node -nodeConfig chromeNodeConfig.json
The other node configs are largely the same except for the different browser names and ports.
Once all nodes are started, the console looks as follows:
I'm not able to get much from the exception. Is it a versioning issue of the drivers I have? I have tried customising my DesiredCapabilities to ensure I'm matching those in the node config. All of that looks fine.
As requested I'm adding a bit more detail as to how I'm trying to launch a browser. None of the browsers work with the RemoteWebDriver whereas they do with the local drivers. Showing the Chrome example - only difference between each is regarding the Capabilities that I'm passing in to the base class constructor.
In my test class
[TestClass]
public class PersonTests : PersonTestBase
{
public PersonTests()
: base(DesiredCapabilities.Chrome())
{
}
[TestCategory("Chrome")]
[TestMethod]
public void Chrome_ShouldCreatePlacement()
{
this.ShouldCreatePerson();
}
}
In my base class I am doing the following
public abstract class PersonTestBase
{
protected IWebDriver Driver;
protected ICapabilities Capabilities;
protected string TargetUrl;
protected string GridUrl;
protected PersonTests(ICapabilities capabilities)
{
this.Capabilities = capabilities;
}
[TestInitialize]
public void TestInitialize()
{
TargetUrl = "http://urlOfMyWebsite";
GridUrl = "http://localhost:4444/wd/hub"
Driver = new RemoteWebDriver(new Uri(GridUrl), Capabilities);
}
[TestCleanup]
public void TestCleanup()
{
Driver.Quit();
}
protected void ShouldCreatePerson()
{
Driver.Navigate().GoToUrl(TargetUrl);
//rest of test code ommitted
}
}
Selenium Remote Webdriver: It is an class that is used to execute the browser automation and to execute assessments in a distributed environment or on a remote computing device. In other words, It is a class that implements the WebDriver interface and this action is performed on the remote server.
Selenium RemoteWebDriver : Difference between WebDriver and RemoteWebDriver. Selenium Webdriver is a tool used to execute automated test cases on various browsers. The object of the WebDriver is a browser. Selenium RemoteWebDriver implements the WebDriver interface to execute test cases.
According to this answer you can also hit a URL ( http://localhost:4444/selenium-server/driver?cmd=shutDownSeleniumServer ) at the end of your test to shutdown the Selenium server.
V3.5.1 Fixes this issue.
Upgrade your Selenium NuGET package using NuGET manager & your selenium-standalone jar.
Downgrade to 3.3.0 until this issue gets resolved and a new release of Selenium Standalone Server is available (Recommended solution)
Or
go //dotnet:release
Note: This workaround does NOT fix anything! It ignores the piece of selenium grid code that causes failure.
Another note: Be aware that upgrading to Selenium 3.4 may require upgrading webdrivers as well
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With