Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Turning off logging in Selenium (from Python)

I've recently inherited some Selenium Webdriver code, written in Python 2.7. It is logging copious amounts of data to /tmp on Ubuntu - so much that it is becoming a problem. I am trying to turn it off (or at least down).

I have been running around trying to RTFM, but this is a new version of Selenium (2.19.0) and the manuals aren't written yet!

I can see there is a method called set_browser_log_level(logLevel) which sounds promising, but to get to it, I need to instantiate a selenium.selenium.selenium object. I don't otherwise have to instantiate one of these, and it takes a lot of parameters (which host? what port?) that I am not expecting to have to provide.

Clearly, I am misunderstanding something.

Can someone please explain either (a) how to turn off logging, or (b) what service is it that selenium.selenium.selenium.selenium.selenium (I may have got carried away there, sorry!) wants to talk to?


Related question: In Selenium, how do I turn off logging? This is an older version of Selenium, and calling it from the scripting language, I believe.
like image 361
Oddthinking Avatar asked Feb 10 '12 10:02

Oddthinking


People also ask

How do I disable selenium logging?

EnableVerboseLogging - false to disable verbose logging for the ChromeDriver executable. SuppressInitialDiagnosticInformation - when set to true the initial diagnostic information is suppressed when starting the driver server executable.

Is the logging feature enabled or disabled by default in selenium WebDriver?

Turns out, ChromeDriver has a default switch that enables logging – --enable-logging ; you need to pass this to Selenium to turn it off.

What is logging in selenium Python?

Logging with python seleniumLogs provide developers with an extra set of eyes that are constantly looking at the flow that an application is going through. They can store information, like which user or IP accessed the application.


1 Answers

Here's what helped me to overcome the problem:

import logging from selenium.webdriver.remote.remote_connection import LOGGER LOGGER.setLevel(logging.WARNING) 

Note: this code should be put before webdriver initialization.

Hope that helps.

like image 126
alecxe Avatar answered Sep 29 '22 09:09

alecxe