Proxies for selenium rc driver in java

How can I configure proxies for selenium in Java?

I connect to 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 a free proxy without username and password credentials for the same one that will run the selenium application in the Safari browser.

I tried the code below to set proxies for tests

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

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

Please suggest me some way to solve the problem.

Thanks at Advance !!

+6
source share
3 answers

You can configure the run configuration under the netbeans network. Project Properties โ†’ Run. Best wishes.

0
source

You can add the desired ip to the proxy bypass field in the global network settings.

0
source

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

Define a property:

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

Reading in java:

 System.getProperty("server_ip"); 

It is more flexible than hardcoded values โ€‹โ€‹in code.

0
source

Source: https://habr.com/ru/post/911563/


All Articles