0
0
Selenium Pythontesting~5 mins

Logging setup in Selenium Python - Cheat Sheet & Quick Revision

Choose your learning style9 modes available
Recall & Review
beginner
What is the purpose of logging in Selenium Python tests?
Logging helps track what happens during test runs. It records events, errors, and important information to understand test behavior and debug issues.
Click to reveal answer
beginner
Which Python module is commonly used for logging in Selenium tests?
The built-in logging module is used to add logging to Selenium Python tests.
Click to reveal answer
intermediate
How do you set the logging level to show only warnings and errors?
Use logging.basicConfig(level=logging.WARNING) to show warnings and errors but hide info and debug messages.
Click to reveal answer
beginner
What is the benefit of logging to a file instead of the console?
Logging to a file saves logs for later review. This helps when you want to check test results after they run or keep a history.
Click to reveal answer
beginner
Show a simple example to set up logging in a Selenium Python script.
import logging
logging.basicConfig(filename='test.log', level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s')
logging.info('Test started')
# Your Selenium code here
logging.info('Test finished')
Click to reveal answer
Which logging level shows the most detailed information?
AWARNING
BDEBUG
CERROR
DINFO
What does the logging.basicConfig() function do?
ASets up the logging system configuration
BStarts the Selenium browser
CRuns the test cases
DImports the logging module
Why might you want to log messages with timestamps?
ATo know when events happened during the test
BTo make logs colorful
CTo speed up the test execution
DTo reduce log file size
Which of these is NOT a standard logging level?
AERROR
BCRITICAL
CTRACE
DINFO
How can you log an error message in Selenium Python?
Aselenium.log('Error message')
Bprint('Error message')
Clog.error('Error message')
Dlogging.error('Error message')
Explain how to set up basic logging in a Selenium Python script and why it is useful.
Think about how logging helps track test progress and issues.
You got /4 concepts.
    Describe the difference between logging to the console and logging to a file in Selenium tests.
    Consider when you want to see logs immediately vs. keep them for later.
    You got /4 concepts.