Class Debug

java.lang.Object
org.openqa.selenium.internal.Debug

public class Debug extends Object
Decides whether Selenium's Java bindings run in debug mode and exposes Selenium's diagnostic log records when they do.

Debug mode is a convenience for troubleshooting. It is switched on by either of these:

  • the selenium.debug system property, or the legacy selenium.webdriver.verbose property, which only affect the Java bindings' java.util.logging output; or
  • the SE_DEBUG environment 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 Type
    Method
    Description
    static void
    Shows Selenium's diagnostic log records on the console if debugging is enabled.
    static Level
    Deprecated, for removal: This API element is subject to removal in a future version.
    Log diagnostics at a fixed level such as Level.FINE.
    static boolean
    Returns whether the SE_DEBUG environment variable is set to true.
    static boolean
    Returns whether the selenium.debug or selenium.webdriver.verbose system property is currently set to true.

    Methods inherited from class Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Method Details

    • isDebugging

      public static boolean isDebugging()
      Returns whether the selenium.debug or selenium.webdriver.verbose system property is currently set to true.

      The properties are read on every call, so a value set after Selenium's classes are loaded is honoured.

      Returns:
      true if either debug system property is currently enabled
    • getDebugLogLevel

      @Deprecated(forRemoval=true) public static Level getDebugLogLevel()
      Deprecated, for removal: This API element is subject to removal in a future version.
      Log diagnostics at a fixed level such as Level.FINE. configureLogger() makes those records visible when debugging is enabled.
      Returns the level that legacy call sites use for their diagnostic messages.
      Returns:
      Level.INFO while isDebugging() is true, Level.FINE otherwise
    • isDebugAll

      public static boolean isDebugAll()
      Returns whether the SE_DEBUG environment variable is set to true.

      The first time this returns true, a warning is printed to System.err.

      Returns:
      true if SE_DEBUG is 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.selenium logger lets Level.FINE records 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.INFO to System.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 accepts FINE records will see those records twice. Records at INFO and above are left to the handlers that already print them, such as the root logger's console handler, so a user who turns off useParentHandlers on org.openqa.selenium must 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