Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Modify logging level on Selenium Firefox driver?

I'm running tests for a Java/Maven project using Selenium 3.4 and the FirefoxDriver (not the Marionette/Geckodriver). I have Firefox 45.9.0 installed. Our test code uses Log4j2 and I can set the logging level to whatever I like, but no matter what I set it to I get log messages like this in the console:

1501873908911   addons.manager  DEBUG   Application has been upgraded
1501873909216   addons.manager  DEBUG   Loaded provider scope for resource://gre/modules/addons/XPIProvider.jsm: ["XPIProvider"]
1501873909218   addons.manager  DEBUG   Loaded provider scope for resource://gre/modules/LightweightThemeManager.jsm: ["LightweightThemeManager"]
1501873909220   addons.manager  DEBUG   Loaded provider scope for resource://gre/modules/addons/GMPProvider.jsm
1501873909221   addons.manager  DEBUG   Loaded provider scope for resource://gre/modules/addons/PluginProvider.jsm
1501873909221   addons.manager  DEBUG   Starting provider: XPIProvider
1501873909221   addons.xpi  DEBUG   startup
1501873909222   addons.xpi  INFO    Mapping [email protected] to C:\TMP\anonymous3169069284131523935webdriver-profile\extensions\[email protected]
1501873909222   addons.xpi  DEBUG   Ignoring file entry whose name is not a valid add-on ID: C:\TMP\anonymous3169069284131523935webdriver-profile\extensions\webdriver-staging
1501873909223   addons.xpi  INFO    SystemAddonInstallLocation directory is missing
1501873909224   addons.xpi  INFO    Mapping [email protected] to C:\Program Files (x86)\Mozilla Firefox\browser\features\[email protected]
1501873909226   addons.xpi  INFO    Mapping {972ce4c6-7e08-4474-a285-3208198ce6fd} to C:\Program Files (x86)\Mozilla Firefox\browser\extensions\{972ce4c6-7e08-4474-a285-3208198ce6fd}.xpi
1501873909226   addons.xpi  DEBUG   Skipping unavailable install location app-system-share
1501873909226   addons.xpi  DEBUG   Skipping unavailable install location app-system-local

It looks like something inside the FirefoxDriver, or inside Firefox itself, is logging at a DEBUG level no matter what I set our logging level to.

I looked at this question but I can't figure out how to translate the Python answer to our Java code:

Example Python:

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

Our Java code:

DesiredCapabilities capability = DesiredCapabilities.firefox();
FirefoxProfile profile=new FirefoxProfile();
capability.setCapability(FirefoxDriver.PROFILE, profile);
mDriver = new FirefoxDriver(capability);

I've tried several permutations but nothing seems to affect this logging - these messages appear in the console no matter what. Anyone have any way to control this logging?

like image 535
user1071914 Avatar asked Jul 27 '26 22:07

user1071914


1 Answers

These log are from selenium library, if you don't want to see it => turn it off by declare the scope of logging to only in your package or simply turn it off.

For example you just want to get log message from your code, the root package of your code is: com.example.mycode then open the log4j config file and add this: log4j.logger.com.example.mycode = DEBUG|INFO.

Or you can turn off only the logging from selenium: java.util.logging.Logger.getLogger("org.openqa.selenium").setLevel(Level.OFF);

like image 182
TuyenNTA Avatar answered Jul 29 '26 10:07

TuyenNTA



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!