0
0
Selenium Pythontesting~10 mins

Logging setup in Selenium Python - Interactive Code Practice

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

Complete the code to import the logging module.

Selenium Python
import [1]
Drag options to blanks, or click blank then click option'
Alogging
Bsys
Cos
Dselenium
Attempts:
3 left
💡 Hint
Common Mistakes
Importing unrelated modules like sys or os.
Forgetting to import the logging module.
2fill in blank
medium

Complete the code to set the logging level to DEBUG.

Selenium Python
logging.basicConfig(level=[1])
Drag options to blanks, or click blank then click option'
Alogging.INFO
Blogging.ERROR
Clogging.DEBUG
Dlogging.WARNING
Attempts:
3 left
💡 Hint
Common Mistakes
Using INFO or WARNING which show fewer messages.
Using ERROR which only shows errors.
3fill in blank
hard

Fix the error in the code to log an info message.

Selenium Python
logging.[1]("Test started")
Drag options to blanks, or click blank then click option'
Ainfo
Bdebug
Cwarn
Dloginfo
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'warn' which is deprecated; should use 'warning'.
Using a non-existent method like 'loginfo'.
4fill in blank
hard

Fill both blanks to create a logger and set its level to WARNING.

Selenium Python
logger = logging.getLogger([1])
logger.setLevel([2])
Drag options to blanks, or click blank then click option'
A"selenium_logger"
Blogging.DEBUG
Clogging.WARNING
D"root"
Attempts:
3 left
💡 Hint
Common Mistakes
Using DEBUG level when WARNING is required.
Using root logger name when a custom name is better.
5fill in blank
hard

Fill all three blanks to add a file handler that writes logs to 'app.log' with ERROR level.

Selenium Python
file_handler = logging.FileHandler([1])
file_handler.setLevel([2])
logger.addHandler([3])
Drag options to blanks, or click blank then click option'
A"app.log"
Blogging.ERROR
Cfile_handler
D"error.log"
Attempts:
3 left
💡 Hint
Common Mistakes
Using the wrong filename string.
Setting the wrong logging level.
Forgetting to add the handler to the logger.