[英]Proxy for selenium rc driver in java
How can i do proxy configuration for selenium in Java? 如何在Java中为selenium进行代理配置?
I am connecting to selenium with: 我正在连接到selenium:
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. 我想在没有用户名和密码凭据的情况下配置免费代理,以便在safari浏览器中运行selenium应用程序。
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 , 它甚至接受null作为参数,
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: 我更喜欢从控制台定义属性(使用maven)然后在java中读取它:
Define property: 定义属性:
mvn clean verify -Dserver_ip="127.0.0.1" -Dport="4444"
Read in java: 读入java:
System.getProperty("server_ip");
It's more flexible than hardcoded values in code 它比代码中的硬编码值更灵活
You can customize run configuration under netbeans. 您可以在netbeans下自定义运行配置。 Project Properties -> Run. 项目属性 - >运行。 Regards. 问候。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.