System.InvalidOperationException:无法在本地机器上创建新服务:ChromeDriverService 与 ChromeDriver 和 SeleniumGrid [英] System.InvalidOperationException : Unable to create new service: ChromeDriverService with ChromeDriver and SeleniumGrid on local machine

查看:40
本文介绍了System.InvalidOperationException:无法在本地机器上创建新服务:ChromeDriverService 与 ChromeDriver 和 SeleniumGrid的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经在运行 Windows 10 的本地计算机上设置了 Selenium Grid(集线器和节点),使用以下命令注册集线器.

I had set up Selenium Grid (Both Hub and Node) on my local machine which runs on Windows 10 using below command for registering Hub.

java -jar selenium-server-standalone-3.141.59.jar -role hub

为了注册一个节点,我使用了下面的命令

and for registering a Node, I had used below command

java -jar selenium-server-standalone-3.141.59.jar -role node -hub http://10.37.34.2:4444/grid/register -port 5454

在命令提示符下,显示节点已注册到集线器并准备使用"

On Command Prompt, it displayed that "The node is registered to the hub and ready to use"

验证网格控制台以及 http://localhost:4444/grid/console.一切看起来都很好.

Verified Grid Console as well at http://localhost:4444/grid/console. Everything looked fine.

当我在 Visual Studio 中执行一个简单的测试用例时,我看到了以下错误消息.

When I executed a simple test case in visual studio, I saw the below error message.

结果信息:

System.InvalidOperationException : Unable to create new service: ChromeDriverService
Build info: version: '3.141.59', revision: 'e82be7d358', time: '2018-11-14T08:25:53'
System info: host: 'PCD-F3FD2', ip: '10.37.34.2', os.name: 'Windows 10', os.arch: 'x86', os.version: '10.0', java.version: '1.8.0_172'
Driver info: driver.version: unknown (SessionNotCreated)

在 Hub 命令提示符下,我可以看到

On the Hub Command Prompt, I can see

"20:47:46.539 INFO [RequestHandler.process] - Got a request to create a new session: Capabilities {browserName: chrome, goog:chromeOptions: {}, platformName: windows}
20:47:46.542 INFO [TestSlot.getNewSession] - Trying to create a new session on test slot {server:CONFIG_UUID=0c4146b1-d7d9-4f39-91ce-b30c57c53342, seleniumProtocol=WebDriver, browserName=chrome, maxInstances=5, platformName=WIN10, platform=WIN10}"

在节点命令提示符上,我可以看到

On the Node Command Prompt, I can see

20:47:46.601 INFO [ActiveSessionFactory.apply] - Capabilities are: {
"browserName": "chrome",
"goog:chromeOptions": {
},
"platformName": "windows"}


20:47:46.602 INFO [ActiveSessionFactory.lambda$apply$11] - Matched factory org.openqa.selenium.grid.session.remote.ServicedSession$Factory (provider: org.openqa.selenium.chrome.ChromeDriverService)

下面是我的 C# 代码:

Below is my C# code:

[Test]
    public void AccessGoogle()
    {

        ChromeOptions options = new ChromeOptions();
        options.BinaryLocation = @"C:\Program Files (x86)\Google\Chrome\Application\chrome.exe";
        options.PlatformName = PlatformType.Windows.ToString();

        IWebDriver d = new RemoteWebDriver(new Uri("http://10.37.34.2:4444/wd/hub"), options.ToCapabilities());

        d.Manage().Timeouts().ImplicitWait = TimeSpan.FromSeconds(30);

        d.Url = "https://www.google.com/";
    }

你能帮我了解一下出了什么问题吗?

Could you please help me to understand what went wrong?

我也调整了我的机器防火墙设置.但没有运气!

I had tweaked my machines Firewall settings as well. But no luck!

推荐答案

由于您已在本地计算机上设置了 Selenium Grid(集线器和节点),因此在初始化 SeleniumGrid Node你需要通过Dwebdriver.chrome.driver传递ChromeDriver位置的绝对路径strong> 论证如下:

As you have set up Selenium Grid (Both Hub and Node) on your local machine, so while initializng the Selenium Grid Node you need to pass the absolute path of the ChromeDriver location through the Dwebdriver.chrome.driver argument as follows:

java -Dwebdriver.chrome.driver=C:\path\to\chromedriver.exe -jar selenium-server-standalone-3.141.59.jar -role node -hub http://10.37.34.2:4444/grid/register -port 5454

这篇关于System.InvalidOperationException:无法在本地机器上创建新服务:ChromeDriverService 与 ChromeDriver 和 SeleniumGrid的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆