0
votes

I need to set my Browser's proxy with Automatic Proxy configuration URL as shown in the screenshot below.

I am trying to achieve this using Selenium and Browserstack as test environment.

Set the proxy as shown below.

Proxy proxy = new Proxy();
proxy.setProxyAutoconfigUrl("http://pokgsa.ibm.com/gsa/pokgsa/home/j/m/jmit/web/public/proxy.pac");
DesiredCapabilities caps = new DesiredCapabilities();
caps.setCapability(CapabilityType.PROXY, proxy);
caps.setCapability("browser", "Chrome");
caps.setCapability("browser_version", "63.0");
caps.setCapability("os", "Windows");
caps.setCapability("os_version", "7");
caps.setCapability("resolution", "1366x768");

enter image description here

Tried to set the proxy configuration locally and it works however it does not work on browserstack. I think the proxy is not getting set on the virtual browser.

1

1 Answers

1
votes
FirefoxProfile profile = new FirefoxProfile();
profile.setPreference("network.proxy.type", 2);
profile.setPreference("network.proxy.autoconfig_url", "http://pokgsa.ibm.com/gsa/pokgsa/home/j/m/jmit/web/public/proxy.pac");
capabilities.setCapability(FirefoxDriver.PROFILE, profile);

You need to pass the pac file details using Firefox profile.

Similarly for chrome, you may refer the following link: https://github.com/SeleniumHQ/docker-selenium/wiki/Corporate-Proxies#setting-a-proxy-for-running-chrome

Also please ensure proxies in the pac file do not need machine based authentication/entries since this may not work as your proxies would be required to be authenticated on all browserstack IPs