Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /**
- * !!!!! NOTE - now work only with Chrome and HTTP proxy
- * Will be update to working with FF and Socks5 proxy
- * This method was tested on Docker Selenium nodes
- * @param remoteWebDriverURL - url on selenium grid hub(e.g. http://10.10.82.142:4444/wd/hub)/ All project's hub addresses can be found in 'properties' file
- * @param browserName - chrome or firefox
- * @param proxy_ip - ip without port
- * @param port - port as integer
- * @return remote WebDriver
- */
- public static WebDriver initRemoteWebDriverWithProxy(String remoteWebDriverURL, String browserName, String proxy_ip, int port) {
- try {
- DesiredCapabilities capability = DesiredCapabilities.chrome();
- Proxy proxy = new Proxy();
- String ProxyString = proxy_ip + ":" + port;
- proxy.setProxyType(Proxy.ProxyType.MANUAL);
- proxy.setHttpProxy(ProxyString)
- .setFtpProxy(ProxyString)
- .setSocksProxy(ProxyString)
- .setSslProxy(ProxyString);
- capability.setCapability(CapabilityType.PROXY, proxy);
- capability.setBrowserName(browserName);
- capability.setCapability(CapabilityType.PROXY, proxy);
- WebDriver driver = new RemoteWebDriver(new URL(remoteWebDriverURL), capability);
- driver.manage().window().maximize();
- return driver;
- } catch (MalformedURLException e) {
- e.printStackTrace();
- return null;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement