Class Debug
Debug mode is a convenience for troubleshooting. It is switched on by either of these:
- the
selenium.debugsystem property, or the legacyselenium.webdriver.verboseproperty, which only affect the Java bindings'java.util.loggingoutput; or - the
SE_DEBUGenvironment variable, the broader switch also used by Selenium Grid, the other language bindings and the driver services.
Users who need fine-grained control should configure java.util.logging or an SLF4J
bridge themselves instead.
-
Method Summary
Modifier and TypeMethodDescriptionstatic voidShows Selenium's diagnostic log records on the console if debugging is enabled.static LevelDeprecated, for removal: This API element is subject to removal in a future version.static booleanReturns whether theSE_DEBUGenvironment variable is set totrue.static booleanReturns whether theselenium.debugorselenium.webdriver.verbosesystem property is currently set totrue.
-
Method Details
-
isDebugging
public static boolean isDebugging()Returns whether theselenium.debugorselenium.webdriver.verbosesystem property is currently set totrue.The properties are read on every call, so a value set after Selenium's classes are loaded is honoured.
- Returns:
trueif either debug system property is currently enabled
-
getDebugLogLevel
Deprecated, for removal: This API element is subject to removal in a future version.Log diagnostics at a fixed level such asLevel.FINE.configureLogger()makes those records visible when debugging is enabled.Returns the level that legacy call sites use for their diagnostic messages.- Returns:
Level.INFOwhileisDebugging()istrue,Level.FINEotherwise
-
isDebugAll
public static boolean isDebugAll()Returns whether theSE_DEBUGenvironment variable is set totrue.The first time this returns
true, a warning is printed toSystem.err.- Returns:
trueifSE_DEBUGis enabled
-
configureLogger
public static void configureLogger()Shows Selenium's diagnostic log records on the console if debugging is enabled.The switches are read on every call. Once one of them has been seen, debug logging stays on for the life of the JVM, even if the switch is turned off again later. While debugging is on, each call makes sure that:
- the
org.openqa.seleniumlogger letsLevel.FINErecords through. A level that is already more verbose, set on the logger or inherited from a parent, is left as it is; and - one Selenium-owned console handler, which prints records below
Level.INFOtoSystem.err, is attached to that logger. It is re-attached if something removed it.
Handlers added by the user, and the root logger, are never changed. Because Selenium's handler prints every record below
INFO, a user who has also attached a handler that acceptsFINErecords will see those records twice. Records atINFOand above are left to the handlers that already print them, such as the root logger's console handler, so a user who turns offuseParentHandlersonorg.openqa.seleniummust attach their own handler to see them.Calling this method when debugging is disabled does nothing. It is safe to call repeatedly and from several threads.
System.setProperty("selenium.debug", "true"); Debug.configureLogger(); // FINE records from org.openqa.selenium now reach System.err - the
-
Level.FINE.