【问题标题】:Nightwatch: Basic auth with access_key not workingNightwatch:使用 access_key 的基本身份验证不起作用
【发布时间】:2016-08-23 08:33:44
【问题描述】:

我创建了如下的 nightwatch.json 文件(带有用户名和 access_key 属性):

"test_settings": {
        "default": {
            "launch_url": "http://localhost",
            "selenium_port": 4444,
            "selenium_host": "localhost",
            "silent": true,
            "cli_args": {
                "webdriver.firefox.profile": "testprofile"
            },
            "screenshots": {
                "enabled": false,
                "path": "screenshots/"
            },
            "desiredCapabilities": {
                "browserName": "firefox",
                "javascriptEnabled": true,
                "acceptSslCerts": true
            },
            "username": "examplelogin",
            "access_key": "password"
        }

但是基本身份验证不起作用,我在运行测试后得到登录窗口来填写我的密码和登录。我查看了提琴手中的数据包,但没有授权标头。任何想法我做错了什么?

守夜人 v0.9.6

【问题讨论】:

    标签: selenium testing nightwatch.js end-to-end


    【解决方案1】:

    来自:https://groups.google.com/d/msg/nightwatchjs/n-B4HnnzYg8/rmaipXiTsuwJ

    之前回复我自己的帖子 - 请不要混淆用户名和 access_key 变量为“基本身份验证”。它们是基于硒的 可以选择用于验证的验证器 云解决方案。基本身份验证的最佳解决方案是良好的旧 URL 方式。 试试:``` browser.url('https://' + 用户名 + ':' + 密码 + '@' + 你的网址)

    【讨论】:

      【解决方案2】:

      您可以在globals.js 中执行此操作。它将保留凭据并跳过基本身份验证提示。

      beforeEach: function (browser, cb) {
        if (browser.globals.basic_auth_url) {
          browser.url(browser.globals.basic_auth_url, cb);
        } else {
          cb();
        }
      },
      

      basic_auth_url - 添加带有凭据的完整 URL。

      不要将凭据添加到launch_url

      【讨论】:

        猜你喜欢
        • 2014-09-06
        • 2014-01-22
        • 2016-01-11
        • 1970-01-01
        • 1970-01-01
        • 2014-12-31
        • 2016-11-17
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多