【问题标题】:Selenium Proxy on Grid网格上的 Selenium 代理
【发布时间】:2017-05-31 12:41:12
【问题描述】:

我有这个设置,在本地浏览器中设置代理正常,但是当我尝试使用网格时,代理不会被发送到节点:

var driver = new webdriver.Builder()
          .withCapabilities(webdriver.Capabilities.firefox())
          .setProxy(proxy.manual({ http : 'proxy:port',
                                   https : 'proxy:port',
                                     }))

           .build();

结果:浏览器代理是-proxy:port;

当我添加时:

var driver = new webdriver.Builder()
          .withCapabilities(webdriver.Capabilities.firefox())
          .setProxy(proxy.manual({ http : 'proxy:port',
                                   https : 'proxy:port',
                                     }))
          .usingServer('http://hub:port/wd/hub') 
          .build();

结果:浏览器代理是 - 它向我显示集线器的 ip。 问题:有谁知道为什么手动设置代理没有发送到集线器以及为什么浏览器不使用它?或者这个问题的任何其他解决方案?

【问题讨论】:

    标签: selenium firefox proxy grid manual


    【解决方案1】:

    这是有效的解决方案:

    var webdriver = require('selenium-webdriver'),
    firefox = require('selenium-webdriver/firefox'),
    proxy = require('selenium-webdriver/proxy')
    driver = null,
    profile = new firefox.Profile();
    profile.setPreference("network.proxy.type", 1); // Manual proxy config
    profile.setPreference("network.proxy.http", "proxy");
    profile.setPreference("network.proxy.http_port", port);
    profile.setPreference("network.proxy.ssl", "proxy");
    profile.setPreference("network.proxy.ssl_port", port);
    
    var opts = new firefox.Options();
    opts.setProfile(profile);
    var driver = new webdriver.Builder()
      .withCapabilities(webdriver.Capabilities.chrome())
      .setFirefoxOptions(opts);
      .build();
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2022-08-23
      • 1970-01-01
      • 1970-01-01
      • 2021-04-10
      • 2017-11-30
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多