2016-05-23 6 views
0

anpassen Problem in unten stehenden Frage, wie die Proxy-Einstellungen?wie Firefox Proxy-Einstellungen mit Selen

//sample code to add new proxy settings 
firefoxProfile.SetPreference(“network.proxy.http_port”, 8080); 
+0

einen Blick http://stackoverflow.com/questions/9261133/how-can-i-configure-selenium-webdriver-to-use-custom-firefox-setup- für Tests – nullpointer

Antwort

0

Überprüfen Sie den gemeinsamen Code in this answer.

//Code copied from the above link 
FirefoxProfile profile = new FirefoxProfile(); 
String PROXY = "xx.xx.xx.xx:8080"; 
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); 

Set PROXY auf Ihre Proxy-Server-Adresse ein.

Für Java Benutzer

String PROXY = "proxyserver:9999"; 
    org.openqa.selenium.Proxy proxy = new org.openqa.selenium.Proxy(); 
    proxy.setHttpProxy(PROXY); 
    proxy.setFtpProxy(PROXY); 
    proxy.setSslProxy(PROXY); 

    org.openqa.selenium.remote.DesiredCapabilities cap = org.openqa.selenium.remote.DesiredCapabilities.firefox(); 
    cap.setCapability(org.openqa.selenium.remote.CapabilityType.PROXY, proxy); 

    org.openqa.selenium.WebDriver driver = new org.openqa.selenium.firefox.FirefoxDriver(cap); 
Verwandte Themen