Reputation: 1937
I recorded a test case on Chrome and wanted to run the test. When I run it, it just opens up a browser and doesn't add the URL
If I open in Firefox, the URL is added but the proxy settings default to no proxy (but I am behind a firewall)
How do I get the test to run on either Firefox or Chrome?
Please help
Upvotes: 0
Views: 2414
Reputation: 5671
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)
Upvotes: 1