2

こんにちは私はSeleniumWebDriverJavaコード/スクリプトを書いています。

public static WebDriver dr =null;
public static EventFiringWebDriver driver=null;

dr = new FirefoxDriver();

driver = new EventFiringWebDriver(dr);
driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS);

そのため、Firefoxブラウザは開いていますが、プロキシ設定は停止しています。

手動の場合は、[ツール]->[オプション]-[設定]->[このネットワークの自動検出プロキシ設定を指定しました]に移動し
ました。これは機能しています。

しかし、スクリプトで開くと、新しいプロファイルが開いていると思います。そのため、スクリプトを使用して、このネットワークのプロキシ設定の自動検出をtrueに設定しました。

それで、それをする方法を私に助けてくれませんか?

ありがとうラジュ

4

4 に答える 4

4

これは良い解決策です:

import org.openqa.selenium.Proxy.ProxyType;` 

public static WebDriver dr = null;
org.openqa.selenium.Proxy proxy = new org.openqa.selenium.Proxy(); 
proxy.setSslProxy("proxyurl"+":"+8080); 
proxy.setFtpProxy("proxy url"+":"+8080); 
proxy.setSocksUsername("SSSLL277"); 
proxy.setSocksPassword("password"); 

DesiredCapabilities dc = DesiredCapabilities.firefox();
dc.setCapability(CapabilityType.PROXY, proxy); 
dr = new FirefoxDriver(dc);
于 2013-03-21T14:34:13.840 に答える
3

プロファイルのプリファレンスは、少なくともFirefoxドライバーを使用して実行時に設定できます。以下を試してみてください:

FirefoxProfile ff = new FirefoxProfile();
ff.setPreference("network.proxy.type", ProxyType.AUTODETECT.ordinal());
FirefoxDriver ffD = new FirefoxDriver(ff);
于 2013-01-09T14:03:31.710 に答える
1

これは私にとってうまくいった解決策であり、最初の2つを少し組み合わせたものであり、十分に単純です。個別のユーザー認証を行う必要はありませんでした。

import org.openqa.selenium.Proxy.ProxyType;
import org.openqa.selenium.firefox.FirefoxProfile;

FirefoxProfile profile = new FirefoxProfile();
profile.setPreference("network.proxy.type", 1);
profile.setPreference("network.proxy.http", "proxy.something.com");
profile.setPreference("network.proxy.http_port", 8080);
profile.setPreference("network.proxy.ssl", "proxy.something.com");
profile.setPreference("network.proxy.ssl_port", 8080);


WebDriver driver = new FirefoxDriver(profile); 
于 2013-09-11T16:39:24.417 に答える
0

これは、自動検出を設定するために私が行うことです。

FirefoxProfile profile = new FirefoxProfile();
Proxy proxy = new Proxy();
proxy.IsAutoDetect=true;
profile.SetProxyPreferences(proxy);
driver = new FirefoxDriver(profile);
于 2014-02-06T13:01:58.293 に答える