【问题标题】:Issue with BASIC HTTP authentication using Selenium in Python在 Python 中使用 Selenium 的 BASIC HTTP 身份验证问题
【发布时间】:2014-09-09 21:53:04
【问题描述】:

我正在尝试测试一个具有 BASIC 身份验证的 Web 应用程序(当我点击任何页面时,都会弹出一个用于验证用户身份的弹出窗口,该弹出窗口不是 HTML 的一部分)。输入用户名/密码并在弹出窗口中单击“确定”后,将出现主登录页面。

现在,我需要一个策略来在 Firefox 中对弹出窗口中的用户进行身份验证。我尝试了以下查看 Stack Overflow 中的一些旧 atricles 的方法,但这对我不起作用。

有人可以指导我如何进行吗?我安装了 Selenium 2.5.0 并使用 python 编写脚本。

profile = webdriver.FirefoxProfile()
profile.set_preference("network.automatic-ntlm-auth.trusted-uris", "website url")
driver = webdriver.Firefox(firefox_profile=profile)
driver.get("http://username:password@WebsiteURL")

【问题讨论】:

    标签: python http authentication selenium


    【解决方案1】:

    要让这个用户:密码方案正常工作,您需要设置另一个首选项:

    profile.setPreference("network.http.phishy-userpass-length", 255);
    

    Reference

    顺便说一句,您使用的是非常旧的 Selenium 版本。

    【讨论】:

    • 你好 Erki.. 我也尝试过 avbove,但由于某种原因它不起作用。
    猜你喜欢
    • 2016-05-14
    • 1970-01-01
    • 2016-08-10
    • 2022-10-04
    • 2011-12-05
    • 2023-03-20
    • 2011-03-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多