10

I am trying to start selenium and selenium's browser with proxy but not getting success. I have used two methods:

        Properties sysProps = System.getProperties();
        sysProps.put("proxySet", "true");
        sysProps.put("proxyHost", "190.249.188.220");
        sysProps.put("proxyPort", "81");

and

java -jar lib/selenium-server.jar proxyHost=22.52.50.228 proxyPort=80

but both are not supporting.

is anyone able to help me to start selenium's browser with proxy.

2 Answers 2

13

You can use this:

String PROXY = "localhost:8080";

org.openqa.selenium.Proxy proxy = new org.openqa.selenium.Proxy();
proxy.setHttpProxy(PROXY)
     .setFtpProxy(PROXY)
     .setSslProxy(PROXY);
DesiredCapabilities cap = new DesiredCapabilities();
cap.setCapability(CapabilityType.PROXY, proxy);

WebDriver driver = new InternetExplorerDriver(cap);

For more detail, refer here

Sign up to request clarification or add additional context in comments.

Comments

2

try

java -Dhttp.proxyHost=HOSTNAME -Dhttp.proxyPort=PORT -Dhttp.proxyUser=USER -Dhttp.proxyPassword=PASSWORD -jar selenium-server.jar

* Dhttp.proxyHost – proxy IP address
* Dhttp.proxyPort – proxy port
* Dhttp.proxyUser – user name if HTTP-proxy authentication required;
* Dhttp.proxyPassword – user password if HTTP-proxy authentication required.

2 Comments

No, I think its also not supporting because when I am putting wrong proxy (e.i. I am putting my name) then too its opening browser. It should not be open when I am putting wrong proxy.
Like Alex said, seleniumhq.org/docs/05_selenium_rc.html#proxy-configuration. If you want to implement some mechanism that checks whether the given properties are good or bad, you would have to do that on your own. Selenium just takes what you give to it and tries to use it.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.