P A N
P A N

Reputation: 5922

Change log level of Geckodriver for Python Selenium

It appears Selenium 3.0 and above requires geckodriver with Firefox under Python 2.7., which I now have installed. However, it appears that running Selenium with Firefox now automatically creates the file geckodriver.log in the directory running the Python script.

I'd like to stop this from happening. I've looked around at various Github threads looking for an answer, but can't find anything for Firefox for Python. What I could find in geckodriver --help is to set the log level to any of the following:

   --log <LEVEL>
        Set Gecko log level [values: fatal, error, warn, info, config, debug,
        trace]

However, I'm not sure how to do this. Perhaps using something like desired_capabilities or service_args for webdriver.Firefox()?

Upvotes: 4

Views: 2605

Answers (2)

beeart
beeart

Reputation: 71

This did the trick for me icw geckodriver 0.19.1

from selenium.webdriver.firefox.options import Options

opties = Options()
opties.log.level = 'trace'
browser = webdriver.Firefox(options=opties)

Upvotes: 4

Danimal
Danimal

Reputation: 1228

I've just hit trouble trying to increase this log level, but the easiest way to stop it log anything is to redirect to /tmp (or even /dev/null):

webdriver.Firefox(log_path='/tmp/geckodriver.log')

Upvotes: 2

Related Questions