Reputation: 49
I am trying to use Selenium Grid and C# to remotely control a Chrome browser. It used to work but since I installed a new Windows image on my machine B, it does not anymore. However, I am able to use Selenium locally on both computers, so I think it is not a chromedriver problem. For remote control, I run the following commands in machine A and machine B respectively:
java -jar C:\Users\FlcUser\Downloads\selenium-server-standalone-3.141.5.jar -role hub -host 10.1.1.14
java -Dwebdrive.chrome.drive="C:\Temp\chromedriver.exe" -jar C:\Temp\selenium-server-standalone-3.141.5.jar -role node -hub http://10.1.1.14:4444/grid/register
The node is successfully registered and then I run this C# code (I don't know if what I have commented is necessary but it doesn't change the error):
ChromeOptions options = new ChromeOptions();
//options.BinaryLocation = "C:\\Temp\\chromedriver.exe";
IWebDriver driver = new RemoteWebDriver(new Uri("http://10.1.1.14:4444/wd/hub"), options.ToCapabilities(), TimeSpan.FromSeconds(180));
I get this error:
Unable to create new service: ChromeDriverService
I have read a lot about it, and I tried many things. I updated everything. I've made sure that my chromedriver version is compatible with my browser and I also have the last version of Java (https://java.com/en/download/, in both machines).
These are the logs I get in cmd:
Machine A:
17:48:23.746 INFO [DefaultGridRegistry.add] - Registered a node http://10.24.25.237:19016
17:50:19.814 INFO [RequestHandler.process] - Got a request to create a new session: Capabilities {browserName: chrome, goog:chromeOptions: {}}
17:50:35.155 INFO [TestSlot.getNewSession] - Trying to create a new session on test slot {server:CONFIG_UUID=2dac93b3-8952-4c62-bcee-3c5febe21545, seleniumProtocol=WebDriver, browserName=chrome, maxInstances=5, platformName=WIN10, platform=WIN10}
Machine B:
21:48:31.497 INFO [ActiveSessionFactory.apply] - Capabilities are: {
"browserName": "chrome",
"goog:chromeOptions": {}}
21:48:31.497 INFO [ActiveSessionFactory.lambda$apply$11] - Matched factory org.openqa.selenium.grid.session.remote.ServicedSession$Factory (provider: org.openqa.selenium.chrome.ChromeDriverService)
And this is the exception Visual Studio throws:
System.InvalidOperationException was unhandled
HResult=-2146233079
Message=Unable to create new service: ChromeDriverService
Build info: version: '3.141.5', revision: 'd54ebd709a', time: '2018-11-06T11:58:47'
System info: host: 'FLCOMPACT', ip: '10.1.1.25', os.name: 'Windows 10', os.arch: 'x86', os.version: '10.0', java.version: '1.8.0_191'
Driver info: driver.version: unknown (SessionNotCreated)
Source=WebDriver
StackTrace:
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, TimeSpan commandTimeout)
at SeleniumPrueba.Program.Main(String[] args) in d:\SeleniumDemo\SeleniumPrueba\Program.cs:line 21
at System.AppDomain._nExecuteAssembly(RuntimeAssembly assembly, String[] args)
at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
at System.Threading.ThreadHelper.ThreadStart()
InnerException:
Finally, I have tried the same with other computers and I got the same error, so I am doing wrong. I think it is related with Java or chromedriver because I used to run this VS Code solution without problems. I updated also the libraries in Visual Studio via NuGet.
How can I solve this?
Upvotes: 0
Views: 1798
Reputation: 193338
The issue seems to be in the command you have used to start the Selenium Grid Node which instead of being:
java -Dwebdrive.chrome.drive="C:\Temp\chromedriver.exe" -jar C:\Temp\selenium-server-standalone-3.141.5.jar -role node -hub http://10.1.1.14:4444/grid/register
Should have been:
java -Dwebdriver.chrome.driver=C:/Temp/chromedriver.exe -jar C:/Temp/selenium-server-standalone-3.141.5.jar -role node -hub http://10.1.1.14:4444/grid/register
Note A: The Key is webdriver.chrome.driver
but not webdrive.chrome.drive
Note B: Ensure that the ChromeDriver binary on the Grid Node is placed at C:/Temp/
Upvotes: 1