【问题标题】:Passing basic auth credentials in Google Chrome shows the pop again在 Google Chrome 中传递基本身份验证凭据再次显示弹出窗口
【发布时间】:2019-07-24 23:45:37
【问题描述】:

我正在使用 watir(Ruby selenium 包)尝试使用基本身份验证登录到 url

我这样传递凭据

 https://username:password@nagios.com

但是,当浏览器打开时,我会弹出一个窗口以再次输入凭据。

我使用的代码如下

driver = Watir::Browser.new :chrome
driver.goto "https://username:password@nagios.com"

上面的代码打开浏览器 -> 转到 url 但弹出窗口再次输入凭据。

如何使用基本身份验证登录 url?

【问题讨论】:

  • 什么浏览器?站点或驱动程序目前可能不支持基本身份验证。

标签: authentication selenium-webdriver basic-authentication watir


【解决方案1】:

原来 Chrome 在 52 版本之后已经停止支持在 url 中传递凭据。更多信息https://medium.com/@lmakarov/say-goodbye-to-urls-with-embedded-credentials-b051f6c7b6a3

要解决此问题,您需要在启动浏览器时设置参数--disable-blink-features="BlockCredentialedSubresources"。它的作用是禁用该功能

更多信息Bypass blocking of subresource requests whose URLs contain embedded credentials

这是我最终的有效代码

 args = ['--disable-software-rasterizer',
                    '--disable-blink-features="BlockCredentialedSubresources"',
                    '--no-proxy-server',
                    '--disable-gpu',
                    '--no-sandbox',
                    '--ignore-certificate-errors']
driver = Watir::Browser.new :chrome, options: {args: args}
driver.goto "https://username:password@nagios.com"

【讨论】:

    猜你喜欢
    • 2018-09-14
    • 2020-11-25
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-05-03
    • 1970-01-01
    相关资源
    最近更新 更多