0
0
Selenium Javatesting~20 mins

Logging test steps in Selenium Java - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Logging Mastery Badge
Get all challenges correct to earn this badge!
Test your skills under time pressure!
💻 Command Output
intermediate
2:00remaining
What is the output of this Selenium Java logging code?
Consider the following Selenium Java code snippet that uses java.util.logging.Logger to log test steps. What will be printed to the console?
Selenium Java
import java.util.logging.Logger;
import java.util.logging.Level;

public class TestLogging {
    private static final Logger logger = Logger.getLogger(TestLogging.class.getName());

    public static void main(String[] args) {
        logger.setLevel(Level.INFO);
        logger.info("Starting test execution");
        logger.warning("This is a warning message");
        logger.severe("This is an error message");
    }
}
A
INFO Starting test execution
WARNING This is a warning message
SEVERE This is an error message
B
INFO: Starting test execution
WARNING: This is a warning message
SEVERE: This is an error message
C
Starting test execution
This is a warning message
This is an error message
DError: Logger not initialized
Attempts:
2 left
💡 Hint
Look at the default format of java.util.logging.Logger output.
Configuration
intermediate
2:00remaining
Which configuration enables detailed logging for Selenium WebDriver in Java?
You want to enable detailed logging for Selenium WebDriver actions in your Java test. Which option correctly sets the logging level to show all messages?
ALogger.getLogger("org.selenium").setLevel(Level.WARNING);
BLogger.getLogger("selenium").setLevel(Level.SEVERE);
CLogger.getLogger("webdriver").setLevel(Level.OFF);
DLogger.getLogger("org.openqa.selenium").setLevel(Level.ALL);
Attempts:
2 left
💡 Hint
The Selenium WebDriver logs are under the 'org.openqa.selenium' package.
🔀 Workflow
advanced
2:00remaining
What is the correct order to add logging to Selenium test steps?
Arrange the steps in the correct order to add logging for Selenium test steps in Java.
A1,2,3,4
B2,1,3,4
C1,3,2,4
D3,1,2,4
Attempts:
2 left
💡 Hint
Think about initializing logger before using it and logging before and after actions.
Troubleshoot
advanced
2:00remaining
Why does this Selenium Java test not show any log output?
Given this code snippet, why might no log messages appear on the console? import java.util.logging.Logger; public class Test { private static final Logger logger = Logger.getLogger(Test.class.getName()); public static void main(String[] args) { logger.info("Test started"); } }
AThe default logging level is higher than INFO, so INFO messages are not shown
BThe main method is not executed
CThe code is missing a call to logger.start()
DLogger is not initialized properly, causing no output
Attempts:
2 left
💡 Hint
Check the default logging level for java.util.logging.Logger.
Best Practice
expert
2:00remaining
Which is the best practice for logging Selenium test steps in Java?
Choose the best practice for logging test steps in Selenium Java tests to ensure clear, maintainable logs.
AAvoid logging to keep tests fast and clean
BLog every single WebDriver command at SEVERE level to catch all errors
CUse descriptive messages with test step details and log at appropriate levels (INFO, WARNING, SEVERE)
DUse System.out.println for all logging to simplify output
Attempts:
2 left
💡 Hint
Think about clarity and usefulness of logs for debugging.