我正在尝试使用Selenium的Chrome Webdriver和C#自动登录网站。运行以下代码将引发屏幕截图1和2中列出的错误。我究竟做错了什么?谷歌搜索错误似乎没有显示任何相关的结果。Selenium Chrome Webdriver不能正常工作
using System.Drawing.Imaging;
using System.IO;
using OpenQA.Selenium.Chrome;
namespace WebDriverTest
{
class Program
{
static void Main(string[] args)
{
// Initialize the Chrome Driver
using (var driver = new ChromeDriver())
{
// Go to the home page
driver.Navigate().GoToUrl("https://twitter.com/");
// Get User Name field, Password field and Login Button
var userNameField = driver.FindElementById("usr");
}
}
}
}
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:61724/session/cc7bae393b288855ed8169dade774baa/element.
The status of the exception was ReceiveFailure, and the message was:
The underlying connection was closed: An unexpected error occurred on a receive.
我相信这是一个版本不匹配。什么是您使用的铬和铬驱动程序的版本? 我会建议尝试与铬56和最新的铬驱动程序2.28。看起来像57铬可能有一些问题。 –