OpenQA.Selenium.WebDriverException
OpenQA.Selenium.WebDriverException
嗨,我有一个 c# window 表单应用程序,它在工作之前使用 selenium 打开边缘,但几个月后我收到此错误
An unhandled exception of type 'OpenQA.Selenium.WebDriverException' occurred in WebDriver.dll
Additional information: A exception with a null response was thrown sending an HTTP request to the remote WebDriver server for URL http://localhost:53335/session. The status of the exception was ReceiveFailure, and the message was: The underlying connection was closed: An unexpected error occurred on a receive.
这是堆栈跟踪
at OpenQA.Selenium.Remote.HttpCommandExecutor.MakeHttpRequest(HttpRequestInfo requestInfo)
at OpenQA.Selenium.Remote.HttpCommandExecutor.Execute(Command commandToExecute)
at OpenQA.Selenium.Remote.DriverServiceCommandExecutor.Execute(Command commandToExecute)
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.Edge.EdgeDriver..ctor(EdgeDriverService service, EdgeOptions options, TimeSpan commandTimeout)
at OpenQA.Selenium.Edge.EdgeDriver..ctor(EdgeDriverService service, EdgeOptions options)
at OpenQA.Selenium.Edge.EdgeDriver..ctor(EdgeDriverService service)
at XRF_Reader.DPRS_Main.XRF_Reader_Load(Object sender, EventArgs e) in c:\Users\****\Documents\projects\DPRS\DPRS\DPRS_Main.cs:line 75
at System.Windows.Forms.Form.OnLoad(EventArgs e)
at MetroFramework.Forms.MetroForm.OnLoad(EventArgs e)
at System.Windows.Forms.Control.CreateControl(Boolean fIgnoreVisible)
at System.Windows.Forms.Control.CreateControl()
at System.Windows.Forms.Control.WmShowWindow(Message& m)
at System.Windows.Forms.Control.WndProc(Message& m)
at MetroFramework.Forms.MetroForm.WndProc(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
at System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
我用
Selenium 网络驱动程序 - v 3.141.0
selenium webdriver IE v 3.141.0
这是我的代码
var driverService = EdgeDriverService.CreateDefaultService();
EdgeOptions options = new EdgeOptions();
//var driver = new EdgeDriver(driverService);
edgeDriver = new EdgeDriver(driverService);
edgeDriver.Navigate().GoToUrl(Config.SpcUrl);
对于 Microsoft Edge 42.17134.1.0,MicrosoftEdge HTML 17.17134.
您可以从 this link 下载 Release 17134 版本的 Edge WebDriver。
然后使用如下代码使用webDriver(驱动路径改成你自己的):
using OpenQA.Selenium;
using OpenQA.Selenium.Edge;
namespace ecwebdriver
{
public class edgewebdriver
{
static void Main(string[] args)
{
var driverpath = @"C:\Windows\System32";
using (var driver = new EdgeDriver(driverpath))
{
// Navigate to Bing
driver.Url = "https://www.bing.com/";
// Find the search box and query for webdriver
var element = driver.FindElementById("sb_form_q");
element.SendKeys("webdriver");
element.SendKeys(Keys.Enter);
driver.Quit();
}
}
}
}
对于 Edge Chromium 版本(81.0.416.72(官方构建)(64 位))
从 here or install it via Nuget package 下载 Selenium 4.00-alpha05 的 C# 绑定。
从this page下载匹配版本的 Microsoft Edge 驱动程序。
然后,使用以下代码(将驱动程序路径和网站 url 更改为您自己的):
using OpenQA.Selenium.Edge;
using System.Threading;
namespace ecwebdriver
{
public class edgewebdriver
{
static void Main(string[] args)
{
EdgeOptions edgeOptions = new EdgeOptions();
edgeOptions.UseChromium = true;
edgeOptions.BinaryLocation = @"C:\Program Files (x86)\Microsoft\Edge\Application\msedge.exe";
var msedgedriverDir = @"E:\webdriver";
var driver = new EdgeDriver(msedgedriverDir, edgeOptions);
driver.Navigate().GoToUrl("<website url>");
Thread.Sleep(3000);
driver.Close();
}
}
}
嗨,我有一个 c# window 表单应用程序,它在工作之前使用 selenium 打开边缘,但几个月后我收到此错误
An unhandled exception of type 'OpenQA.Selenium.WebDriverException' occurred in WebDriver.dll
Additional information: A exception with a null response was thrown sending an HTTP request to the remote WebDriver server for URL http://localhost:53335/session. The status of the exception was ReceiveFailure, and the message was: The underlying connection was closed: An unexpected error occurred on a receive.
这是堆栈跟踪
at OpenQA.Selenium.Remote.HttpCommandExecutor.MakeHttpRequest(HttpRequestInfo requestInfo)
at OpenQA.Selenium.Remote.HttpCommandExecutor.Execute(Command commandToExecute)
at OpenQA.Selenium.Remote.DriverServiceCommandExecutor.Execute(Command commandToExecute)
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.Edge.EdgeDriver..ctor(EdgeDriverService service, EdgeOptions options, TimeSpan commandTimeout)
at OpenQA.Selenium.Edge.EdgeDriver..ctor(EdgeDriverService service, EdgeOptions options)
at OpenQA.Selenium.Edge.EdgeDriver..ctor(EdgeDriverService service)
at XRF_Reader.DPRS_Main.XRF_Reader_Load(Object sender, EventArgs e) in c:\Users\****\Documents\projects\DPRS\DPRS\DPRS_Main.cs:line 75
at System.Windows.Forms.Form.OnLoad(EventArgs e)
at MetroFramework.Forms.MetroForm.OnLoad(EventArgs e)
at System.Windows.Forms.Control.CreateControl(Boolean fIgnoreVisible)
at System.Windows.Forms.Control.CreateControl()
at System.Windows.Forms.Control.WmShowWindow(Message& m)
at System.Windows.Forms.Control.WndProc(Message& m)
at MetroFramework.Forms.MetroForm.WndProc(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
at System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
我用 Selenium 网络驱动程序 - v 3.141.0 selenium webdriver IE v 3.141.0
这是我的代码
var driverService = EdgeDriverService.CreateDefaultService();
EdgeOptions options = new EdgeOptions();
//var driver = new EdgeDriver(driverService);
edgeDriver = new EdgeDriver(driverService);
edgeDriver.Navigate().GoToUrl(Config.SpcUrl);
对于 Microsoft Edge 42.17134.1.0,MicrosoftEdge HTML 17.17134.
您可以从 this link 下载 Release 17134 版本的 Edge WebDriver。
然后使用如下代码使用webDriver(驱动路径改成你自己的):
using OpenQA.Selenium;
using OpenQA.Selenium.Edge;
namespace ecwebdriver
{
public class edgewebdriver
{
static void Main(string[] args)
{
var driverpath = @"C:\Windows\System32";
using (var driver = new EdgeDriver(driverpath))
{
// Navigate to Bing
driver.Url = "https://www.bing.com/";
// Find the search box and query for webdriver
var element = driver.FindElementById("sb_form_q");
element.SendKeys("webdriver");
element.SendKeys(Keys.Enter);
driver.Quit();
}
}
}
}
对于 Edge Chromium 版本(81.0.416.72(官方构建)(64 位))
从 here or install it via Nuget package 下载 Selenium 4.00-alpha05 的 C# 绑定。
从this page下载匹配版本的 Microsoft Edge 驱动程序。
然后,使用以下代码(将驱动程序路径和网站 url 更改为您自己的):
using OpenQA.Selenium.Edge;
using System.Threading;
namespace ecwebdriver
{
public class edgewebdriver
{
static void Main(string[] args)
{
EdgeOptions edgeOptions = new EdgeOptions();
edgeOptions.UseChromium = true;
edgeOptions.BinaryLocation = @"C:\Program Files (x86)\Microsoft\Edge\Application\msedge.exe";
var msedgedriverDir = @"E:\webdriver";
var driver = new EdgeDriver(msedgedriverDir, edgeOptions);
driver.Navigate().GoToUrl("<website url>");
Thread.Sleep(3000);
driver.Close();
}
}
}