0
0
Selenium Javatesting~10 mins

Logging test steps in Selenium Java - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to create a logger instance named 'logger'.

Selenium Java
Logger logger = Logger.getLogger([1].class.getName());
Drag options to blanks, or click blank then click option'
AWebDriver
BLogger
CSystem
DTestSteps
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'Logger' or 'System' instead of the class name.
Using 'WebDriver' which is unrelated to logging.
2fill in blank
medium

Complete the code to log an info message 'Test started'.

Selenium Java
logger.[1]("Test started");
Drag options to blanks, or click blank then click option'
Ainfo
Bwarn
Cerror
Ddebug
Attempts:
3 left
💡 Hint
Common Mistakes
Using debug or error instead of info for normal messages.
Using warn which is for caution messages.
3fill in blank
hard

Fix the error in the code to log a warning message 'Low disk space'.

Selenium Java
logger.[1]("Low disk space");
Drag options to blanks, or click blank then click option'
Aalert
Bwarning
Cwarn
Dnotice
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'warning' which is not a method in Logger.
Using 'alert' or 'notice' which do not exist in Logger.
4fill in blank
hard

Fill both blanks to log an error with an exception message.

Selenium Java
try {
    // test code
} catch (Exception e) {
    logger.[1]("Error occurred: " + e.[2]());
}
Drag options to blanks, or click blank then click option'
Aerror
BgetMessage
CtoString
DprintStackTrace
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'toString' which returns full exception info, not just message.
Using 'printStackTrace' which prints to console, not returns a string.
5fill in blank
hard

Fill all three blanks to log a debug message with the current test step number.

Selenium Java
int step = 3;
logger.[1]("Executing step " + [2] + ": " + [3]);
Drag options to blanks, or click blank then click option'
Adebug
Bstep
C"Open login page"
Dinfo
Attempts:
3 left
💡 Hint
Common Mistakes
Using info instead of debug for detailed steps.
Using a number literal instead of the variable for step number.