我仍然无法解决这个问题。几天前,我的Selenium还能正常工作;现在它却给我抛出了一些错误。我最初使用NuGet,然后尝试手动安装。
如何重现这个问题:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using OpenQA.Selenium;
using OpenQA.Selenium.Chrome;
using System.Threading.Tasks;
namespace Debug
{
class Program
{
static void Main(string[] args)
{
try
{
IWebDriver driver = new ChromeDriver();
driver.Navigate().GoToUrl("http://stackoverflow.com/");
}
catch (Exception ex)
{
Console.Clear();
Console.WriteLine(ex);
Console.ReadKey();
}
}
}
}
错误:
OpenQA.Selenium.WebDriverException:向远程WebDriver服务器发送HTTP请求的响应为空时抛出异常,URL为http://localhost:60695/session。异常状态为ReceiveFailure,消息为:底层连接关闭:接收时发生意外错误。---> System.Net.WebException:底层连接关闭:接收时发生意外错误。---> System.IO.IOException: 从传输连接无法读取数据:现有连接已被远程主机强制关闭。---> System.Net.Socket
如何安装Selenium:
从http://selenium-release.storage.googleapis.com/3.0/selenium-dotnet-3.0.0.zip
下载Selenium。
然后在VS中将仅dll添加到引用中。