I have some Robot Framework test suites that use the SeleniumLibrary. I run these tests with Firefox and geckodriver. Whenever I run my tests suites, a geckodriver-*.log
file is created.
For example, before I run my test suite, I have only my .robot
file:
$ ls
example.robot
I then run robot, and the geckodriver log file is generated:
$ robot --output NONE --log NONE --report NONE example.robot
<output of running test suite>
$ ls
example.robot geckodriver-1.log
If I rerun the test suite, a geckodriver-2.log
file is created, and running the suite a third time generates a geckodriver-3.log
file, and so on.
How can I run my test suites without any geckodriver log files being created?
I know this must be possible, since it can be done in regular python (without Robot) by setting the service_log_path
to /dev/null
, as below:
from selenium import webdriver
import shutil
driver = webdriver.Firefox(
executable_path=shutil.which('geckodriver'),
service_log_path='/dev/null'
)
driver.get('https://stackoverflow.com/')
driver.quit()
My *.robot
file for a minimal reproducible example
*** Settings ***
Library SeleniumLibrary run_on_failure=None
*** Test Cases ***
Example Test Case
Open Browser https://stackoverflow.com/ Firefox
Close Browser
Version and OS information
The solution is to set the service_log_path
argument for the Open Browser
keyword to os.path.devnull
, as below:
*** Settings ***
Library SeleniumLibrary run_on_failure=None
*** Test Cases ***
Example Test Case
Open Browser https://stackoverflow.com/ Firefox service_log_path=${{os.path.devnull}}
Close Browser
Then geckodriver
will log to os.path.devnull
instead of to a file in the current working directory.
Note: This example uses inline python evaluation, a new feature in Robot Framework 3.2.