Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Firefox in a docker container accessible from selenium in another

I have a docker container running a rails app (let's call it container A) that needs to do some scraping with watir webdriver using firefox as backend.

I have firefox installed in another container (container B) and I want to be able to pass in container A something like:

Selenium::WebDriver::Firefox::Binary.path= $DOCKER_RUN_CONTAINER_A

So, each time watir launches firefox a new instance of CONTAINER_A launches a new firefox.

I know it's easy to make containers communicate using ports, but how about executables? And, by the way, does it look like a good design idea isolating firefox in a separate container?

like image 568
TopperH Avatar asked May 11 '14 19:05

TopperH


1 Answers

Yes, this is easy to do. Just run an instance of Selenium Grid (which is a grid-node hybrid combo by default) , in the foreground on the docker server (on port 5555 or whatever). Then you can use Ruby with Selenium bindings (not WatiR) to drive the firefox browser on the remote box.

like image 162
djangofan Avatar answered Oct 11 '22 13:10

djangofan