EdXX
EdXX

Reputation: 890

How to run webdriver tests on docker firefox-standalone-debug container instead of regular firefox browser

I have a regular Firefox installed on my Linux Ubuntu as well as docker-firefox-standalone-debug container. Moreover I have Xfvb and I set DISPLAY overthere. Now when I run my Webdriver test from Jenkins everything works fine and my test runs on regular Firefox. But the problem is that I would like to start my test now on docker-firefox-standalone-debug container. Can anyone tell me how to force my test on Jenkins to run on docker? By default it starts on regular Firefox and I don't now how to tell him yo run on docker-firefox-debug?

Upvotes: 3

Views: 3706

Answers (2)

EdXX
EdXX

Reputation: 890

I run:

docker run -d -p 32780:4444 -p 5999:5900 selenium/standalone-firefox-debug

so when I type

docker ps

I have

6b7fa91575ae selenium/standalone-firefox-debug "/opt/bin/entry_point" 8 seconds ago Up 6 seconds 0.0.0.0:32780->4444/tcp, 0.0.0.0:5999->5900/tcp

then in my code:

RemoteWebDriver driver = new RemoteWebDriver( 
                                new URL("http://192.168.99.100:32780/wd/hub"), 
                                DesiredCapabilities.firefox());

This works :)

Upvotes: 0

Carlos Rafael Ramirez
Carlos Rafael Ramirez

Reputation: 6234

You'll need to use the remote web driver instead of the regular WebDriver.

For example if you run your conatiner as follows:

docker run -d -p 4444:4444 selenium/standalone-firefox-debug

Use the follwing code:

RemoteWebDriver driver = new RemoteWebDriver(
                    new URL("http://localhost:4444/wd/hub"),
                    DesiredCapabilities.firefox());

Instead of:

WebDriver driver = new FirefoxDriver();

Regards

Upvotes: 3

Related Questions