Firefox用のWebDriverおよびProxy Server
-
04-10-2019 - |
質問
Firefoxのプロキシ設定を設定する方法はありますか?ここではフォキシプロキシに関する情報を見つけましたが、セレンが機能すると、プラグインはウィンドウでアクティブ化されていません。
解決
見る ドキュメントページ.
既存のFirefoxプロファイルを微調整します
「network.proxy.http」& "network.proxy.http_port"プロファイル設定を変更する必要があります。
FirefoxProfile profile = new FirefoxProfile();
profile.addAdditionalPreference("network.proxy.http", "localhost");
profile.addAdditionalPreference("network.proxy.http_port", "3128");
WebDriver driver = new FirefoxDriver(profile);
他のヒント
の価値 network.proxy.http_port
整数である必要があります(見積もりは使用しないでください)。 network.proxy.type
1として設定する必要があります(ProxyType.MANUAL
, 、手動プロキシ設定)
FirefoxProfile profile = new FirefoxProfile();
profile.setPreference("network.proxy.type", 1);
profile.setPreference("network.proxy.http", "localhost");
profile.setPreference("network.proxy.http_port", 3128);
WebDriver driver = new FirefoxDriver(profile);
私は数日間この問題を楽しんだばかりで、httpsの答えを見つけるのは大変でしたので、Javaのための私の見解があります。
FirefoxProfile profile = new FirefoxProfile();
profile.setPreference("network.proxy.type", 1);
profile.setPreference("network.proxy.http", "proxy.domain.example.com");
profile.setPreference("network.proxy.http_port", 8080);
profile.setPreference("network.proxy.ssl", "proxy.domain.example.com");
profile.setPreference("network.proxy.ssl_port", 8080);
driver = new FirefoxDriver(profile);
ここにゴッチャス:ドメインだけでなく、ドメインだけを入力してください http://proxy.domain.example.com
, 、プロパティ名はです .ssl
そしてそうではありません .https
私は今、私の自己署名された証明書を受け入れるようにそれを得ようとしてさらに楽しくなっています...
上記のソリューションに追加するだけです。
「network.proxy.type」の可能性(整数値)のリストを追加します。
0 - Direct connection (or) no proxy.
1 - Manual proxy configuration
2 - Proxy auto-configuration (PAC).
4 - Auto-detect proxy settings.
5 - Use system proxy settings.
したがって、当社の要件に基づいて、「network.proxy.type」値を以下に説明するように設定する必要があります。
FirefoxProfile profile = new FirefoxProfile();
profile.setPreference("network.proxy.type", 1);
WebDriver driver = new FirefoxDriver(profile);
WebDriver APIが変更されました。プロキシを設定するための現在のスニペットはです
FirefoxProfile profile = new FirefoxProfile();
profile.setPreference("network.proxy.http", "localhost");
profile.setPreference("network.proxy.http_port", "3128");
WebDriver driver = new FirefoxDriver(profile);
AutoConfig URLをお持ちの場合 -
FirefoxProfile firefoxProfile = new FirefoxProfile();
firefoxProfile.setPreference("network.proxy.type", 2);
firefoxProfile.setPreference("network.proxy.autoconfig_url", "http://www.etc.com/wpad.dat");
firefoxProfile.setPreference("network.proxy.no_proxies_on", "localhost");
WebDriver driver = new FirefoxDriver(firefoxProfile);
これが使用されているJavaの例です DesiredCapabilities
. 。 SeleniumテストをJMeterに送り込むために使用しました。 (HTTPリクエストにのみ興味がありました)
import org.openqa.selenium.Proxy;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.openqa.selenium.remote.CapabilityType;
import org.openqa.selenium.remote.DesiredCapabilities;
String myProxy = "localhost:7777"; //example: proxy host=localhost port=7777
DesiredCapabilities capabilities = new DesiredCapabilities();
capabilities.setCapability(CapabilityType.PROXY,
new Proxy().setHttpProxy(myProxy));
WebDriver webDriver = new FirefoxDriver(capabilities);
PACベースのURL用
Proxy proxy = new Proxy();
proxy.setProxyType(Proxy.ProxyType.PAC);
proxy.setProxyAutoconfigUrl("http://some-server/staging.pac");
DesiredCapabilities capabilities = new DesiredCapabilities();
capabilities.setCapability(CapabilityType.PROXY, proxy);
return new FirefoxDriver(capabilities);
これが役立つことを願っています。
Firefox Proxy:Java
String PROXY = "localhost:8080";
org.openqa.selenium.Proxy proxy = new org.openqa.selenium.Proxy();
proxy.setHttpProxy(PROXY)setFtpProxy(PROXY).setSslProxy(PROXY);
DesiredCapabilities cap = new DesiredCapabilities();
cap.setCapability(CapabilityType.PROXY, proxy);
WebDriver driver = new FirefoxDriver(cap);
別の解決策があります。このようなコードに問題があるため、私は探しました(Firefoxでシステムプロキシを設定します):
FirefoxProfile profile = new FirefoxProfile();
profile.setPreference("network.proxy.http", "localhost");
profile.setPreference("network.proxy.http_port", "8080");
driver = new FirefoxDriver(profile);
私はこのソリューションを好む、それはFirefoxでプロキシマニュアル設定を強制する。そのために、org.openqa.selenium.proxyオブジェクトを使用してFirefoxをセットアップします。
FirefoxProfile profile = new FirefoxProfile();
localhostProxy.setProxyType(Proxy.ProxyType.MANUAL);
localhostProxy.setHttpProxy("localhost:8080");
profile.setProxyPreferences(localhostProxy);
driver = new FirefoxDriver(profile);
それが役立つなら...
FirefoxProfile profile = new FirefoxProfile();
String PROXY = "xx.xx.xx.xx:xx";
OpenQA.Selenium.Proxy proxy = new OpenQA.Selenium.Proxy();
proxy.HttpProxy=PROXY;
proxy.FtpProxy=PROXY;
proxy.SslProxy=PROXY;
profile.SetProxyPreferences(proxy);
FirefoxDriver driver = new FirefoxDriver(profile);
それはc#のためです
設定 - > Advanced-> Network-> Connection(Firefoxがインターネットに接続する方法を構成)