Webdriver and proxy server for firefox

后端 未结 13 2330
清歌不尽
清歌不尽 2020-11-30 23:49

are there any ways to set firefox\'s proxy settings? I found here information about FoxyProxy but when Selenium works, plugins are unactivated in window.

13条回答
  •  [愿得一人]
    2020-12-01 00:18

    There is another solution, i looked for because a had problems with code like this (it s set the system proxy in firefox):

    FirefoxProfile profile = new FirefoxProfile();
    profile.setPreference("network.proxy.http", "localhost");
    profile.setPreference("network.proxy.http_port", "8080");
    driver = new FirefoxDriver(profile);
    

    I prefer this solution, it force the proxy manual setting in firefox. To do that, use the org.openqa.selenium.Proxy object to setup Firefox :

    FirefoxProfile profile = new FirefoxProfile();
    localhostProxy.setProxyType(Proxy.ProxyType.MANUAL);
    localhostProxy.setHttpProxy("localhost:8080");
    profile.setProxyPreferences(localhostProxy);
    driver = new FirefoxDriver(profile);
    

    if it could help...

提交回复
热议问题