selenium - 系统无效操作异常: Unable to create new service: ChromeDriverService with ChromeDriver and SeleniumGrid on local machine

标签 selenium selenium-webdriver webdriver selenium-chromedriver selenium-grid

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

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

为了注册节点,我使用了以下命令

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

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

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

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

结果消息:

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 命令提示符上,我可以看到

"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}"

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

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# 代码:

[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/";
    }

您能帮助我了解出了什么问题吗?

我也调整了我的机器防火墙设置。但运气不佳!

最佳答案

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

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

关于selenium - 系统无效操作异常: Unable to create new service: ChromeDriverService with ChromeDriver and SeleniumGrid on local machine,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54947684/

相关文章:

java - 线程 "main"org.openqa.selenium.NoSuchElementException : When trying to select an element from a pop-up using selenium 中的异常

javascript - 如何在 Firefox 上使用 Java WebDriver 中的 js 变量

Python:通过CSS选择器查找元素

java - 我可以将变量应用于 Selenium WebDriver 上基于文本的 xPath 搜索吗?

java - 无法使用 driver.close() 关闭窗口

javascript - 如何读取参数值,存在于规范中 Protractor 的conf.js文件中

c# - Selenium WebDriver - Chrome - C# - 无法以隐身模式启动 selenium 浏览器作为最大化浏览器

java - 如何在 firefox headless(java 中的 selenium)中截取屏幕截图?

Python+Selenium,无法点击span包裹的 'button'

python - Selenium:_wait_until_connectable 无限期暂停