public static WebDriver getDriverWithProxy(final String proxyURL,
			final String port, final WebDriver driver) {
		org.openqa.selenium.Proxy proxy = new org.openqa.selenium.Proxy();
		proxy.setHttpProxy(proxyURL + ":" + port)
				.setFtpProxy(proxyURL + ":" + port)
				.setSslProxy(proxyURL + ":" + port);

		DesiredCapabilities cap = new DesiredCapabilities();
		cap.setCapability(CapabilityType.PROXY, proxy);

		try {
			Constructor<?> c = driver.getClass().getConstructor(
					Capabilities.class);
			return (WebDriver) c.newInstance(cap);
		} catch (Exception e) {
			LOG.error(
					"Exception while creating a driver with the specified proxy",
					e);
		}
		return driver;
	}
public static WebDriver getDriverWithProxy ( final String proxyURL , final String port , final WebDriver driver ) { org . openqa . selenium . Proxy proxy = new org . openqa . selenium . Proxy ( ) ; proxy . setHttpProxy ( proxyURL + ":" + port ) . setFtpProxy ( proxyURL + ":" + port ) . setSslProxy ( proxyURL + ":" + port ) ; DesiredCapabilities cap = new DesiredCapabilities ( ) ; cap . setCapability ( CapabilityType . PROXY , proxy ) ; try { Constructor < ? > c = driver . getClass ( ) . getConstructor ( Capabilities . class ) ; return ( WebDriver ) c . newInstance ( cap ) ; } catch ( Exception e ) { LOG . error ( "Exception while creating a driver with the specified proxy" , e ) ; } return driver ; }
Returns a WebDriver object that has the proxy server set.

@param proxyURL
the proxy host
@param port
the proxy port
@param driver
the drive class
@return a new driver with the proxy settings configured