Sistem düzeyi özelliklerini kesinlikle ayarlamanıza gerek yoktur.
FirefoxProfile profile = new FirefoxProfile();
profile.setPreference("network.proxy.type", 1); // Manual proxy config
profile.setPreference("network.proxy.http", "proxy3.proxy.net");
profile.setPreference("network.proxy.http_port", 3128);
profile.setPreference("network.proxy.ssl", "proxy3.proxy.net");
profile.setPreference("network.proxy.ssl_port", 3128);
WebDriver driver = new FirefoxDriver(profile);
Veya daha esnek, daha az tarayıcıya özgü alternatif:
org.openqa.selenium.Proxy proxy = new org.openqa.selenium.Proxy();
proxy.setHttpProxy("proxy3.proxy.net:3128");
proxy.setSslProxy("proxy3.proxy.net:3128");
DesiredCapabilities caps = DesiredCapabilities.firefox(); // or chrome() etc.
caps.setCapability(CapabilityType.PROXY, proxy);
WebDriver driver = new FirefoxDriver(caps);
paylaşmak lütfen çaba –
Önce gibi System.setProperty ile çalıştı: Sistem Bu Firefox'ta bunu yapmak için bir yoldur .setProperty ("http.proxyHost", "proxy3.proxy.net"); \t \t System.setProperty ("http.proxyPort", "3128"); Bu işe yaramadı. Sonra komutun proxy'yi ayarlamak için bir kabuk komutu olduğu Runtime.getRuntime(). Exec (command) ile denedim. –