Monday 17 June 2013

Proxy settings for Remote Webdriver Remotewebdriver

if (browser1.equalsIgnoreCase("firefox")) {

capability = new DesiredCapabilities().firefox();
capability.setBrowserName(browser1);
capability.setJavascriptEnabled(true);

org.openqa.selenium.Proxy proxy = new org.openqa.selenium.Proxy();

String hostname = "proxybc.youcompany.net:8080";
String username = "changeUserid";
String password = "Password1";


proxy.setProxyType(ProxyType.MANUAL);
proxy.setHttpProxy(hostname);
proxy.setSslProxy(hostname);
proxy.setFtpProxy(hostname);
proxy.setSocksUsername(username);
proxy.setSocksPassword(password);




FirefoxProfile fp = new FirefoxProfile();
fp.setProxyPreferences(proxy);
capability.setCapability(FirefoxDriver.PROFILE, fp);
driver = new RemoteWebDriver(new URL("http://"
+ ConfigReader.SELENIUM_SERVER_URL
+ ":".concat(port).concat("/wd/hub")), capability);
browser = new WebDriverBackedSelenium(driver,
ConfigReader.ENVIRONMENT_URL);

jse = (JavascriptExecutor) driver;

driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);
 }

No comments:

Post a Comment