To set proxy in case of Firefox
, you have to use profiles in WebDriver
.
FirefoxProfile profile = new FirefoxProfile();
profile.addAdditionalPreference("network.proxy.http", "localhost");
profile.addAdditionalPreference("network.proxy.http_port", "8888");
WebDriver driver = new FirefoxDriver(profile);
To execute testcase in Chrome
, you need Chromedriver.
System.setProperty("webdriver.chrome.driver", "C:\\chromedriver.exe");
You can set proxy like this.
ChromeOptions options = new ChromeOptions();
Proxy proxy = new Proxy();
proxy.setHttpProxy("localhost:8888");
options.setCapability("proxy", proxy);
ChromeDriver driver = new ChromeDriver(options)