【问题标题】:Browserstack Automate: HTTP Basic Authentication on iOSBrowserstack 自动化:iOS 上的 HTTP 基本身份验证
【发布时间】:2021-06-09 16:17:45
【问题描述】:

我正在使用基于 JavaScript/wdio 的测试套件来测试带有 BrowserStack Automate 的网站。我正在测试的部分页面需要 HTTP 基本身份验证。

BrowserStack 在他们的FAQ for the Screenshot API 中建议使用以下格式: http://username:password@www.xyz.com

虽然这在某些浏览器中有效,但其他浏览器(如 iOS 上的 Safari)似乎不支持在 URL 中提供凭据。我认为有必要将它们作为 HTTP 标头提供。

有没有办法让它工作?

【问题讨论】:

  • 用 appium 版本 '1.16.0' 执行它,它对我有用

标签: automated-tests mobile-safari basic-authentication browserstack


【解决方案1】:

您可以将其添加到功能中:

"safariIgnoreFraudWarning " : "true",

它适用于 iOS。

【讨论】:

    【解决方案2】:

    以下是可以提供帮助的链接: https://www.browserstack.com/docs/automate/selenium/basic-http-authentication#pass-username-and-password-in-the-url

    它说 Safari 不支持通过在 URL 中传递用户名和密码的基本身份验证。

    有一种方法可以使用JavascriptExecutor。我在提交表单后出现 BasicAuthentication 弹出窗口时使用它。

    // here code that submits the form / clicks the link etc which brings you to basic auth
    caps.setCapability("unhandledPromptBehavior", "ignore"); 
    JavascriptExecutor jse = (JavascriptExecutor)driver;
    jse.executeScript("browserstack_executor: {\"action\": \"sendBasicAuth\", \"arguments\": {\"username\":\"<username>\", \"password\": \"<password>\", \"timeout\": \"<time in milliseconds>\"}}");
    

    这对我的情况有用。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2010-12-30
      • 2021-03-21
      • 2011-11-12
      • 2011-05-05
      相关资源
      最近更新 更多