0

任何人都知道如何使这项工作?见截图。尽管凭据是在 url 中传递的,但 IE11 会打开该死的基本身份验证提示: 在此处输入图像描述

$ npm run test:browserstack:ie11 -- --mode integration --url "https://someuser:somepassword@some.url"

package.json
  "test:browserstack:ie11": "vue-cli-service test:browserstack -c browserstack_config/nightwatch.conf.js -e ie11",

部门:

"@vue/cli-plugin-e2e-nightwatch": "^3.8.0",
"nightwatch": "^1.1.13",
"vue-cli-plugin-e2e-nightwatch-browserstack": "^1.2.8",

配置:

ie11: {
  desiredCapabilities: {
    browser: 'internet explorer',
    version: '11',
    platform: 'WINDOWS',
    'browserstack.selenium_version': '3.6.0'
  }
},
4

1 回答 1

0

您的浏览器设置正确。它可以帮助我修复我的测试配置。

但是您似乎忘记传递 API 密钥,所以我将与您分享我的设置:

当您至少在可用于节点 14 的最后一个版本中使用 vue-cli-plugin-e2e-nightwatch-browserstack 时:

进入你项目中的 browserstack_config/nightwatch.conf.js 文件,如果你使用 CLI 工具将插件添加到你的 vue 应用程序中,它将被创建:


    const path = require('path')
    const deepmerge = require('deepmerge')
    const chromedriver = require('chromedriver')
    
    const startHeadless = process.env.VUE_NIGHTWATCH_HEADLESS === '1'
    const concurrentMode = process.env.VUE_NIGHTWATCH_CONCURRENT === '1'
    const userOptions = JSON.parse(process.env.VUE_NIGHTWATCH_USER_OPTIONS || '{}')
    const chromeArgs = []
    const geckoArgs = []
    
    // user may have not installed geckodriver
    let geckodriver = {}
    try {
      geckodriver = require('geckodriver')
    } catch (e) {}
    
    if (startHeadless) {
      chromeArgs.push('headless')
      geckoArgs.push('--headless')
    }
    
    const defaultSettings = {
      src_folders: ['tests/e2e/specs'],
      output_folder: 'tests/e2e/reports/junit',
      page_objects_path: 'tests/e2e/page-objects',
      custom_assertions_path: 'tests/e2e/custom-assertions',
      custom_commands_path: 'tests/e2e/custom-commands',
      test_workers: concurrentMode,
    
      test_settings: {
        default: {
          launch_url: '${VUE_DEV_SERVER_URL}',
          detailed_output: !concurrentMode,
          globals: {
            waitForConditionTimeout: 5000,
          },
        },
        chrome: {
          desiredCapabilities: {
            browserName: 'chrome',
            chromeOptions: {
              w3c: false,
              args: chromeArgs,
            },
          },
        },
        firefox: {
          desiredCapabilities: {
            browserName: 'firefox',
            alwaysMatch: {
              acceptInsecureCerts: true,
              'moz:firefoxOptions': {
                args: geckoArgs,
              },
            },
          },
          webdriver: {},
        },
        ie11: {
          desiredCapabilities: {
            browser: 'internet explorer',
            version: '11',
            platform: 'WINDOWS',
            'browserstack.selenium_version': '3.6.0'
          }
        },
      },
    }
    const baseSettings = deepmerge(defaultSettings, webdriverServerSettings())
    module.exports = deepmerge(baseSettings, adaptUserSettings(userOptions))
    
    function adaptUserSettings(settings) {
      // The path to nightwatch external globals file needs to be made absolute
      // if it is supplied in an additional config file, due to merging of config files
      if (settings.globals_path) {
        settings.globals_path = path.resolve(settings.globals_path)
      }
    
      return settings
    }
    
    function webdriverServerSettings() {
      return {
        selenium: {
          start_process: false,
          host: 'hub-cloud.browserstack.com',
          port: 443,
          cli_args: {
            'webdriver.chrome.driver': chromedriver.path,
            'webdriver.gecko.driver': geckodriver.path,
          },
        },
        test_settings: {
          default: {
            desiredCapabilities: {
              'browserstack.user':
                process.env.BROWSERSTACK_USERNAME || 'BROWSERSTACK_USERNAME',
              'browserstack.key':
                process.env.BROWSERSTACK_ACCESS_KEY || 'BROWSERSTACK_ACCESS_KEY',
              build: process.env.BROWSERSTACK_BUILD || 'default_build',
              project: process.env.BROWSERSTACK_PROJECT || 'default_project',
              'browserstack.debug': true,
              'browserstack.local': true,
            },
          },
          chrome: {
            desiredCapabilities: {
              'browserstack.user':
                process.env.BROWSERSTACK_USERNAME || 'BROWSERSTACK_USERNAME',
              'browserstack.key':
                process.env.BROWSERSTACK_ACCESS_KEY || 'BROWSERSTACK_ACCESS_KEY',
              build: process.env.BROWSERSTACK_BUILD || 'default_build',
              project: process.env.BROWSERSTACK_PROJECT || 'default_project',
              'browserstack.debug': true,
              'browserstack.local': true,
            },
          },
          ie11: {
            desiredCapabilities: {
              'browserstack.user':
                  process.env.BROWSERSTACK_USERNAME || 'BROWSERSTACK_USERNAME',
              'browserstack.key':
                  process.env.BROWSERSTACK_ACCESS_KEY || 'BROWSERSTACK_ACCESS_KEY',
              build: process.env.BROWSERSTACK_BUILD || 'default_build',
              project: process.env.BROWSERSTACK_PROJECT || 'default_project',
              'browserstack.debug': true,
            },
          },
        },
      }
    }

然后在控制台中确保导出您的环境变量:BROWSERSTACK_USERNAME 和 BROWSERSTACK_ACCESS_KEY。另外,您可能希望为 BROWSERSTACK_BUILD 和 BROWSERSTACK_PROJECT 这样做 Linux od MacOS 的示例:

export BROWSERSTACK_USERNAME=<My User Name> 
export BROWSERSTACK_ACCESS_KEY=<access key>

窗口中的相同示例:

$Env:BROWSERSTACK_USERNAME=<My User Name> 
$Env:BROWSERSTACK_ACCESS_KEY=<access key>

精确:

vue-cli-service test:browserstack -c browserstack_config/nightwatch.conf.js -e ie11 tests/e2e/specs/test.js

那可能工作得很好。

你的问题是我的答案,我希望这是你的。

谢谢。

于 2021-07-07T16:05:32.073 回答