Here I have stored proxy url, user name, password in config.properties file and calling to here.. other wise you can give details directly over here as well.
//Proxy settings
org.openqa.selenium.Proxy proxy = new org.openqa.selenium.Proxy();
proxy.setProxyType(ProxyType.MANUAL);
proxy.setHttpProxy(CONFIG.getProperty("hostname"));
proxy.setSslProxy(CONFIG.getProperty("hostname"));
proxy.setFtpProxy(CONFIG.getProperty("hostname"));
proxy.setSocksUsername(CONFIG.getProperty("username"));
proxy.setSocksPassword(CONFIG.getProperty("password"));
DesiredCapabilities cap = new DesiredCapabilities();
cap.setCapability(CapabilityType.PROXY, proxy);
//DesiredCapabilities capabilities = DesiredCapabilities.chrome();
//capabilities.setCapability("chrome.switches", Arrays.asList("--proxy-server=http://user name:password@proxyurl:8080"));
// WebDriver driver = new ChromeDriver(capabilities);
driver = new ChromeDriver(cap);
builder = new Actions(driver);
bckdbrowser = new WebDriverBackedSelenium(driver,
ConfigReader.ENVIRONMENT_URL);
driver.manage().timeouts().implicitlyWait(10,TimeUnit.SECONDS );
Just in case if you use this one.. you can use this way...
ReplyDeletecapabilities.setCapability("chrome.switches", Arrays.asList("--proxy-server=http://" + CONFIG.getProperty("username") + ":" + CONFIG.getProperty("password") + "@" + CONFIG.getProperty("hostname")));
ah ok and thanks for Chrome Proxy
ReplyDelete