【问题标题】:io.github.bonigarcia.wdm.WebDriverManagerException: A response error is detected: HTTP/1.1 403 Forbidden error using WebDriverManager and FireFoxio.github.bonigarcia.wdm.WebDriverManagerException:检测到响应错误:HTTP/1.1 403 Forbidden error using WebDriverManager and FireFox
【发布时间】:2019-11-19 09:38:03
【问题描述】:

我在 Firefox 中运行我的 Selenium 自动化代码并收到以下错误: io.github.bonigarcia.wdm.WebDriverManagerException: A response error is detected: HTTP/1.1 403 Forbidden

在 Chrome 浏览器中运行良好。

FireFox 版本:70.0.1(64 位)

操作系统:Mac 操作系统

【问题讨论】:

    标签: selenium selenium-webdriver firefox selenium-firefoxdriver webdriver-manager


    【解决方案1】:

    此错误消息...

    io.github.bonigarcia.wdm.WebDriverManagerException: A response error is detected: HTTP/1.1 403 Forbidden
    

    ...观察到托管在 GitHub 上的一些二进制文件(用于 Opera 和 Firefox)。


    根据WebDriverManagerException: A response error is detected: HTTP/1.1 403 Forbidden 中的讨论,Boni García 将此问题称为webdrivermanager 中的已知问题。

    Known issues 部分记录了:

    一些二进制文件(用于 Opera 和 Firefox)托管在 GitHub 上。当 WebDriverManager 发出多个连续请求时,GitHub 服务器返回 HTTP 403 错误响应如下:

    Caused by: java.io.IOException: Server returned HTTP response code: 403 for URL: https://api.github.com/repos/operasoftware/operachromiumdriver/releases
        at sun.net.www.protocol.http.HttpURLConnection.getInputStream0(HttpURLConnection.java:1840)
        at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1441)
        at sun.net.www.protocol.https.HttpsURLConnectionImpl.getInputStream(HttpsURLConnectionImpl.java:254)
        at io.github.bonigarcia.wdm.BrowserManager.openGitHubConnection(BrowserManager.java:463)
        at io.github.bonigarcia.wdm.OperaDriverManager.getDrivers(OperaDriverManager.java:55)
        at io.github.bonigarcia.wdm.BrowserManager.manage(BrowserManager.java:168)
          
    

    还有一段时间:

    Caused by: java.io.IOException: Server returned HTTP response code: 403 for URL: https://api.github.com/repos/mozilla/geckodriver/releases
        at sun.net.www.protocol.http.HttpURLConnection.getInputStream0(HttpURLConnection.java:1840)
        at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1441)
        at sun.net.www.protocol.https.HttpsURLConnectionImpl.getInputStream(HttpsURLConnectionImpl.java:254)
        at io.github.bonigarcia.wdm.FirefoxDriverManager.getDrivers(FirefoxDriverManager.java:61)
        at io.github.bonigarcia.wdm.BrowserManager.manage(BrowserManager.java:163)
    

    可以通过发送经过身份验证的请求来解决此问题。流程如下:

    1. 在您的 GitHub 帐户中创建令牌/密钥对。

    2. 告诉 WebDriverManager 这对令牌/秘密的值。为此,您应该使用配置键wdm.gitHubTokenNamewdm.gitHubTokenSecret。您可以将它们作为命令行 Java 参数传递,如下所示:

       -Dwdm.gitHubTokenName=<your-token-name>
       -Dwdm.gitHubTokenSecret=<your-token-secret>
      

    ...或作为环境变量(例如在 Travis CI 中)如下:

        WDM_GITHUBTOKENNAME=<your-token-name>
        WDM_GITHUBTOKENSECRET=<your-token-secret>
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-04-02
      • 2017-08-09
      • 2011-03-18
      相关资源
      最近更新 更多