I have an application that uses Selenium WebDriver to control FireFox. It runs as a Web Application under Tomcat - yes, this is a bit of an odd architecture, but there are g
I think you were pretty close. Though the following line in tomcat.conf
looks perfect:
JAVA_OPTS="-Dwebdriver.gecko.driver=/opt/gecko/geckodriver"
But I am still not sure if -Dwebdriver.firefox.driver=/usr/bin/firefox
is a requirement for you.
As per Class FirefoxDriver.SystemProperty the value of webdriver.firefox.driver
refers to the Constant Field DRIVER_XPI_PROPERTY which is the System property that defines the location of the webdriver.xpi
browser extension to install in the browser. If not set, the prebuilt extension bundled with this class will be used. Unless absolutely necessary this Constant Field must be left untouched.
So dropping -Dwebdriver.firefox.driver=/usr/bin/firefox
will solve the issue.
A bit more details about your usecase would have helped us to debug the issue in a better way. However as you have mentioned Xvfb
is installed and running you need to take care of a couple of facts as mentioned below:
The correct usage of headless mode with GeckoDriver v0.24.0 is:
options.headless = True
There is no need for xvfb-run
anymore if you set MOZ_HEADLESS=1
as follows:
$ export MOZ_HEADLESS=1 # this way you only have to set it once
You can find a detailed discussion in How to make firefox headless programmatically in Selenium with python?
driver.quit()
within tearDown(){}
method to close & destroy the WebDriver and Web Client instances gracefully.