user1164061
user1164061

Reputation: 4352

Running selenium tests from Jenkins - cannot find firefox

I have some selenium tests written in java and built using maven. The pom file includes the jbehave and selenium libraries. It uses firefox browser. So I installed firefox on linux and included the path in my .bashrc. If I do a mvn clean install manually , it works fine.

But if I try the same thing using Jenkins ( am trying to automate the tests), it is throwing errors:

[ERROR] FATAL ERROR
[INFO] ------------------------------------------------------------------------
[INFO] null
Cannot find firefox binary in PATH. Make sure firefox is installed. OS appears to be: LINUX
Caused by: org.openqa.selenium.WebDriverException: Cannot find firefox binary in PATH. Make sure firefox is installed. OS appears to be: LINUX

I tried doing an echo of PATH within Jenkins and it did not show the path of firefox. So I also did an export PATH with the new path of firefox included and then called mvn clean install in Jenkins. Even though the PATH now showed the path of firefox in jenkins console output, it still throws the same error.

What is that I am missing?

Upvotes: 2

Views: 7308

Answers (2)

Dev
Dev

Reputation: 36

Three things to check:

1) as @shawnzhu said, check whether you have installed firefox properly?

2) To provide Binary path to your driver, you need to set system property. Use below code for selenium with java:

File firefoxPathBinary = new File("path/to/your//firefox-bin");
System.setProperty("webdriver.firefox.bin", firefoxPathBinary.getAbsolutePath());
driver = new FirefoxDriver();

3) For Ubuntu, path to your firefox executable could be - usr/lib/firefox/firefox-bin and for Mac it could be /Applications/Firefox.app/Contents/MacOS/firefox-bin

Upvotes: 2

Anubhav Agarwal
Anubhav Agarwal

Reputation: 11

You probably need to link the executable:

sudo unlink /usr/bin/firefox
sudo ln -s /path/to/new/firefox/executable /usr/bin/firefox

Upvotes: 0

Related Questions