简体   繁体   中英

Proxy for selenium rc driver in java

How can i do proxy configuration for selenium in Java?

I am connecting to selenium with:

Process p = Runtime.getRuntime().exec("java -jar lib/selenium-server.jar");
selenium = new DefaultSelenium("localhost", 4444, "*safari", "www.example.com");

I want to configure free proxy without username and password credentials for the same which would be running the selenium application in the safari browser.

I have tried the code below to set proxy for the tests

System.setProperty("http:proxyHost","207.229.122.162"); System.setProperty("http:proxyPort","3128");

but the above code is not working fine !! its even accepting null as arguments ,

Please suggest me some way to resolve the issue !!

Thanks in Advance !!

您可以将所需的ip添加到全局网络设置中的代理绕过字段。

I prefer to define properties from console(using maven) then read it in java:

Define property:

mvn clean verify -Dserver_ip="127.0.0.1" -Dport="4444"

Read in java:

System.getProperty("server_ip");

It's more flexible than hardcoded values in code

You can customize run configuration under netbeans. Project Properties -> Run. Regards.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM