【问题标题】:Protractor proxy settings configuration is not passed to SaucelabsProtractor 代理设置配置未传递给 Saucelabs
【发布时间】:2016-07-10 00:05:11
【问题描述】:

为了让 saucelabs 代理能够在旧版本的量角器中工作,我们通过在 index.js 下面设置主机和端口来覆盖 sendRequest 方法:

量角器\node_modules\selenium-webdriver\http\index.js

现在量角器允许您通过功能对象(如下所示)设置代理,该对象应传递给 index.js sendRequest 新参数,称为“opt_proxy”。

capabilities: {
    "browserName": "chrome",
    'proxy': {
        'proxyType': 'manual',
        'httpProxy': 'appproxy.web.abc.com:84'
    },
    "chromeOptions": {
        "args": [
            "--disable-extensions",
            "--test-type"
        ]
    },
    "customData": {
        "usageBracket" : "1",
        "displayName"  : "Chrome",
        "id"    : "CH"
    }
}

但是,当我仍然为 opt_proxy 获得空值时。有什么我做错了吗?我什至尝试使用 --proxy="" 通过 CLI,但它仍然为空。

【问题讨论】:

    标签: proxy protractor saucelabs


    【解决方案1】:

    我已经使用 Protractor 中提供的 sauceAgent 实用程序将代理配置与 Sauce Labs 一起使用。这是我的量角器配置文件中的代码 sn-p。

    var HttpsProxyAgent = require("https-proxy-agent");
    var agent = new HttpsProxyAgent('http://localhost:56193'); //Insert your proxy info here
    
    exports.config = {
      sauceUser: process.env.SAUCE_USERNAME,
      sauceKey: process.env.SAUCE_ACCESS_KEY,
      sauceAgent: agent,
    

    【讨论】:

    • 我需要在功能中保留代理设置吗?
    • 功能中的代理设置不会传递给 Sauce Labs。如果您的测试框架的其他方面需要它们,那么您可能希望保留它们。
    【解决方案2】:
    capabilities: {
        browserName: 'chrome',
        chromeOptions: {
          args: [
            '--proxy-server=socks5://host:port',
          ]
        },
      },
    

    【讨论】:

      猜你喜欢
      • 2014-12-05
      • 2014-03-22
      • 1970-01-01
      • 2015-03-06
      • 2015-10-06
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多