Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

I am not able to use proxy servers with Chrome #2697

Open
escor888 opened this issue Feb 7, 2022 · 6 comments
Open

I am not able to use proxy servers with Chrome #2697

escor888 opened this issue Feb 7, 2022 · 6 comments

Comments

@escor888
Copy link

escor888 commented Feb 7, 2022

I have tried a lot of things and nothing is working.

  1. Add proxy to maven global settings.xml
  2. Add serenity.proxy.http= www-proxy.us.xxx.com and serenity.proxy.http_port = 80 in serenity.properties
  3. Create my custom webdriver with chromeoptions.
  4. Implements BeforeAWebdriverScenario class.
  5. Add proxy in chrome.switches in serenity.properties

btw there is not much information about my own web driver implementation as well as the try 4.

@escor888
Copy link
Author

escor888 commented Feb 7, 2022

Error shown: ERR_TUNNEL_CONNECTION_FAILED

@wakaleo
Copy link
Member

wakaleo commented Feb 7, 2022

Can you make it work with plain Selenium?

@escor888
Copy link
Author

escor888 commented Feb 7, 2022

I need to check it,
don't we have documentation about proxy in chrome? I think should be a common scenario.
btw in some places I am seeing serenity.proxy.http is only supported by Firefox, is it?

@escor888
Copy link
Author

escor888 commented Feb 7, 2022

is this a good try?
public class MyCapabilityEnhancer implements BeforeAWebdriverScenario {

@Override
public DesiredCapabilities apply(EnvironmentVariables environmentVariables,
                                 SupportedWebDriver driver,
                                 TestOutcome testOutcome,
                                 DesiredCapabilities capabilities) {
    
    if (driver == SupportedWebDriver.CHROME) {
        System.out.println("enhancing chrome capabilities");
        System.out.println(capabilities);
        Proxy proxy = new Proxy();
        proxy.setHttpProxy("http://www-proxy.us.xxx.com:80");
        capabilities.setCapability("proxy", proxy); 
        System.out.println(capabilities);
    }
    return capabilities;
}

}

@wakaleo
Copy link
Member

wakaleo commented Feb 8, 2022

That could work. If that is the only configuration you need to do, then serenity.proxy.http should work. See

for documentation on the proxy settings - they should work for all browsers.

@muthu5151
Copy link

Hi Team,

Even I am facing the same issue when I try to configure http proxy settings for chrome. I have provided the below configuration in serenity.properties file,

serenity.proxy.http = localhost
serenity.proxy.http_port = 8181

Error message:

Caused by: java.lang.NullPointerException
at net.serenitybdd.core.webdriver.driverproviders.ConfiguredProxy.definedIn(ConfiguredProxy.java:64)
at net.serenitybdd.core.webdriver.driverproviders.ChromeDriverCapabilities.addProxyConfigurationTo(ChromeDriverCapabilities.java:104)
at net.serenitybdd.core.webdriver.driverproviders.ChromeDriverCapabilities.configuredOptions(ChromeDriverCapabilities.java:74)
at net.serenitybdd.core.webdriver.driverproviders.ChromeDriverCapabilities.getCapabilities(ChromeDriverCapabilities.java:42)
at net.serenitybdd.core.webdriver.driverproviders.ChromeDriverProvider.enhancedCapabilitiesConfiguredIn(ChromeDriverProvider.java:73)
at net.serenitybdd.core.webdriver.driverproviders.ChromeDriverProvider.newInstance(ChromeDriverProvider.java:50)
at net.thucydides.core.webdriver.WebDriverFactory.createWebDriver(WebDriverFactory.java:157)
at net.thucydides.core.webdriver.WebDriverFactory.newWebdriverInstance(WebDriverFactory.java:136)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants