【问题标题】:WebDriverIO Selenium pass command line arguments into Chrome from config.js fileWebDriverIO Selenium 将命令行参数从 config.js 文件传递​​到 Chrome
【发布时间】:2015-12-20 20:23:18
【问题描述】:

我需要 chrome 使用 disable-web-security 标志运行我的 UI 测试。如何使用 wdio.config 文件 (http://webdriver.io/) 注入任何命令。

  capabilities: [{
        browserName: 'chrome'
    }]

【问题讨论】:

    标签: javascript google-chrome selenium webdriver-io chrome-web-driver


    【解决方案1】:

    您可以使用 goog:chromeOptions 在所需功能范围内设置任何 chrome 标志

    capabilities: [{
        browserName: 'chrome',
        'goog:chromeOptions': {
            args: ['disable-web-security']
        }
    }]
    

    查看the chromedriver docs 了解有关 chromeOptions 对象的更多信息。

    【讨论】:

      【解决方案2】:

      这最终是正确的语法,感谢 Christian!

        capabilities: [{
              browserName: 'chrome',
               'goog:chromeOptions': {
                  args: ['--disable-web-security']
              }
          }]
      

      【讨论】:

        【解决方案3】:

        如果您想使用 webdriverio 在浏览器中禁用 javascript,则需要在 wdio.config 中

        capabilities: [{
            browserName: 'chrome',
             'goog:chromeOptions': {
                    "args" : ["start-fullscreen"],
                    "prefs" : {
                            'profile.managed_default_content_settings.javascript': 2
                    }
            }
        }]
        

        【讨论】:

          【解决方案4】:

          由于@wdio/cli 版本5.11.13chromedriver 版本76.0.0 我无法传递参数chromeOptions - 结果:invalid argument: unrecognized capability: chromeOptions,所以某些内容已更改。

          我做了一些研究并通过goog:chromeOptions 作品:

            capabilities: [{
              browserName: 'chrome',
              'goog:chromeOptions': {
                args: ['--disable-web-security'],
              },
            }]
          

          【讨论】:

            猜你喜欢
            • 1970-01-01
            • 1970-01-01
            • 1970-01-01
            • 1970-01-01
            • 2017-12-18
            • 2011-09-28
            • 1970-01-01
            • 1970-01-01
            • 1970-01-01
            相关资源
            最近更新 更多