我在使用 Selenium 4 从 Csharp 的 Visual Studio 运行 Selenium Grid 时遇到问题。我不断收到错误消息:
信息:
System.InvalidOperationException : Could not start a new session. Could not start a new session. Error while creating session with the driver service. Stopping driver service: Driver server process died prematurely.
Build info: version: '4.1.1', revision: 'e8fcc2cecf'
System info: host: 'ATTPA-1450', ip: '172.26.0.1', os.name: 'Windows 10', os.arch: 'amd64', os.version: '10.0', java.version: '11.0.12'
Driver info: driver.version: unknown
Build info: version: '4.1.1', revision: 'e8fcc2cecf'
System info: host: 'ATTPA-1450', ip: '172.26.0.1', os.name: 'Windows 10', os.arch: 'amd64', os.version: '10.0', java.version: '11.0.12'
Driver info: driver.version: unknown
Build info: version: '4.1.1', revision: 'e8fcc2cecf'
System info: host: 'ATTPA-1450', ip: '172.26.0.1', os.name: 'Windows 10', os.arch: 'amd64', os.version: '10.0', java.version: '11.0.12'
Driver info: driver.version: unknown (SessionNotCreated)
TearDown : System.NullReferenceException : Object reference not set to an instance of an object.
堆栈跟踪:
WebDriver.UnpackAndThrowOnError(Response errorResponse)
WebDriver.Execute(String driverCommandToExecute, Dictionary`2 parameters)
WebDriver.StartSession(ICapabilities desiredCapabilities)
WebDriver.ctor(ICommandExecutor executor, ICapabilities capabilities)
RemoteWebDriver.ctor(ICommandExecutor commandExecutor, ICapabilities desiredCapabilities)
RemoteWebDriver.ctor(Uri remoteAddress, ICapabilities desiredCapabilities, TimeSpan commandTimeout)
WebDriverFactory.OpenBrowser() line 28
BaseTest.Test_Setup() line 54*
你能告诉我我错过了什么吗?我从这个位置下载了 .jar 文件 - https://www.selenium.dev/downloads/
这是我的代码(我最初使用 http://localhost:4444/wd/hub)但仍然遇到相同的错误:
当我将代码更改为
我收到这个错误
_driver = new RemoteWebDriver(new Uri("http://localhost:4444/wd/hub"), browserOptions);
信息:
OpenQA.Selenium.WebDriverException : The HTTP request to the remote WebDriver server for URL http://localhost:4444/wd/hub/session timed out after 60 seconds.
----> System.Threading.Tasks.TaskCanceledException : The operation was canceled.
----> System.IO.IOException : Unable to read data from the transport connection: The I/O operation has been aborted because of either a thread exit or an application request..
----> System.Net.Sockets.SocketException : The I/O operation has been aborted because of either a thread exit or an application request.
TearDown : System.NullReferenceException : Object reference not set to an instance of an object.*