Selenium with Edge:一个带有“null"响应的异常 [英] Selenium with Edge: A exception with a `null` response

查看:57
本文介绍了Selenium with Edge:一个带有“null"响应的异常的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在使用 Selenium 和 Edge 时遇到问题.我使用 .NET Core 3.0.

I have a problem with using Selenium with Edge. I use .NET Core 3.0.

这是我的简单测试:

[Fact]
public void EdgeDriverTest1() {
    using (IWebDriver driver = new EdgeDriver()) {
        driver.Navigate().GoToUrl("http://www.google.com");
        IWebElement element = driver.FindElement(By.Name("q"));
        element.SendKeys("Hello, Selenium WebDriver!");
        element.Submit();
    }
}

当我运行它时,Edge 窗口将被打开并出现错误:

When I run it Edge window will be opened and I get the error:

OpenQA.Selenium.WebDriverException :带有 null 响应的异常被抛出向远程 WebDriver 服务器发送 HTTP 请求URL http://localhost:60127/session.异常状态为UnknownError,消息为:发送时发生错误请求

OpenQA.Selenium.WebDriverException : A exception with a null response was thrown sending an HTTP request to the remote WebDriver server for URL http://localhost:60127/session. The status of the exception was UnknownError, and the message was: An error occurred while sending the request

Nuget 包:

我该如何解决?

推荐答案

您的代码是正确的,出现此错误的主要原因是您使用的 Microsoft WebDriver 版本与您使用的 Edge 版本不匹配.

Your code is right and this error occurs mainly because the Microsoft WebDriver version you're using doesn't match the Edge version you're using.

如果您使用的是 18 之前的 Edge 版本,您可以在 此链接.如果您的 Microsoft Edge 版本为 18 或更高,您可以根据 这篇文章.

If you're using Edge version prior to 18, you can download the appropriate webdriver for your installed version of Microsoft Edge in this link. If your Microsoft Edge version is 18 or higher, you can install the appropriate webdriver version according to the ways in this article.

这篇关于Selenium with Edge:一个带有“null"响应的异常的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆