I have tried so many things to set the proxy in a chrome-in-docker browser.
I finally found something that works, but it isn't the best solution.
@BeforeEach
public void beforeEach(@Arguments("--proxy-server=server:portNum") WebDriver driver) {
this.registrationPage = new RegistrationPage(driver);
this.registrationPage.navigateTo();
}
This works when I run the tests in Jenkins (Needs proxy there) but will fail the tests when running locally.
Is there a better way to set the proxy server, or to set it conditionally?
My code runs in Java with maven. I would be fine with adding a system property to Jenkins (-Dis.CI=true or whatever) but I can only figure out how to set these arguments as a method paramter. That definitly won't work for conditionally setting them.
Any other way to set the --proxy-server is greatly appreciated. I would also prefer a way to set this globally. Having to set it in every test class would be a nightmare.
I have tried using WebDriverManager.globalConfig().setProxy("...") and it had no effect. I'm under the assumption that the proxy in the config is different than the proxy-server.