StringPROXY="localhost";intPORT=8080;com.google.gson.JsonObjectjson=newcom.google.gson.JsonObject();json.addProperty("proxyType","MANUAL");json.addProperty("httpProxy",PROXY);json.addProperty("httpProxyPort",PORT);json.addProperty("sslProxy",PROXY);json.addProperty("sslProxyPort",PORT);DesiredCapabilitiescap=newDesiredCapabilities();cap.setCapability("proxy",json);GeckoDriverServiceservice=newGeckoDriverService.Builder(firefoxBinary).usingDriverExecutable(newFile("path to geckodriver")).usingAnyFreePort().usingAnyFreePort().build();service.start();// GeckoDriver currently needs the Proxy set in RequiredCapabilitiesdriver=newFirefoxDriver(service,cap,cap);