I have configured a proxy. I can check with curl that I can browse an url via proxy and it works. But in the browser session created by selenium I'm browsing through mi normal ip, not my proxy. I've setted my proxy in selenium with the variable
SE_OPTS="-Dhttp.proxyHost=172.17.0.1 -Dhttp.proxyPort=8123".
Thank you in advance.
I also cannot configure a proxy server for the Firefox neither setting proxy options via standard Linux environment vars nor passing the above JVM options.
However, even for standalone, non-Dockerized Selenium, proxy navigation has been always a headache because of lack of docs on doing it via command-line (all docs are for test's code). Some docs mention Ffx profiles that I don't know if can be done inside Docker.
Perhaps some documenting to the image would be in order, after knowing if/how is it done.
Proxy server can be set for your browser using Desired capabilities object in the code when trying to launch the browser using selenium in the code. Look at this link on how to provide proxy details -
https://github.com/SeleniumHQ/selenium/wiki/DesiredCapabilities#proxy-json-object
@ashutoshmittal2309 is correct. you need to specify proxy information within your selenium DesiredCapabilities.
The problem for me is not being able to set a proxy from _outside the code_ of the Selenium tests, when deploying/running the tests as Ops. For instance, if you don't have the code available or don't know/want to modify it.
Assuming an HTTP proxy at 172.17.0.1 port 8123, the following env vars in a Docker Compose manifest worked, so far (however, since I'm not sure which one is the correct, I set them all):
all_proxy=http://172.17.0.1:8123
http_proxy=http://172.17.0.1:8123
https_proxy=http://172.17.0.1:8123
ALL_PROXY=http://172.17.0.1:8123
HTTP_PROXY=http://172.17.0.1:8123
HTTPS_PROXY=http://172.17.0.1:8123
SE_OPTS=-Dhttp.proxyHost=172.17.0.1 -Dhttp.proxyPort=8123
This docker-compose.yml file works
version: '2.2'
# docker-compose --force-recreate
services:
firefox:
image: selenium/standalone-firefox:2.53.0
ports:
- 4444:4444
volumes:
- /dev/shm:/dev/shm
environment:
- TZ=CET - no_proxy=127.0.0.1,localhost,.test,schiphol.nl
- http_proxy=http://172.17.0.1:8128
- https_proxy=http://172.17.0.1:8128
- SE_OPTS=-Dhttp.proxyHost=172.17.0.1 -Dhttp.proxyPort=8128
Thank you, @bbaassssiiee !
Let鈥檚 let the solution be the last and stop comment.