0
0
Selenium Pythontesting~10 mins

Performance metrics collection 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 start performance logging in Selenium.

Selenium Python
driver = webdriver.Chrome()
driver.[1]('performance')
Drag options to blanks, or click blank then click option'
Astart_log
Bstart_performance_logging
Cenable_performance
Dbegin_logging
Attempts:
3 left
💡 Hint
Common Mistakes
Using a method that does not exist like start_performance_logging.
Using enable_performance which is not a valid method.
2fill in blank
medium

Complete the code to retrieve performance logs from the driver.

Selenium Python
logs = driver.get_log('[1]')
Drag options to blanks, or click blank then click option'
Abrowser
Bdriver
Cperformance
Dnetwork
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'browser' or 'network' which are different log types.
Using 'driver' which is not a valid log type.
3fill in blank
hard

Fix the error in the code to correctly parse performance logs.

Selenium Python
for entry in logs:
    message = json.loads(entry['[1]'])
    print(message)
Drag options to blanks, or click blank then click option'
Alog
Bmessage
CmessageText
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'messageText' or 'log' which do not exist in the log entry.
Using 'message' with wrong capitalization.
4fill in blank
hard

Fill both blanks to filter performance logs for network events.

Selenium Python
network_events = [entry for entry in logs if '[1]' in json.loads(entry['message'])['[2]']]
Drag options to blanks, or click blank then click option'
ANetwork.responseReceived
Bmethod
Cparams
DNetwork.requestWillBeSent
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'params' instead of 'method' as the key.
Using 'Network.requestWillBeSent' which is a different event.
5fill in blank
hard

Fill all three blanks to extract URL, status, and timing from network response logs.

Selenium Python
for event in network_events:
    msg = json.loads(event['[1]'])
    url = msg['[2]']['response']['url']
    status = msg['[3]']['response']['status']
    print(f"URL: {url}, Status: {status}")
Drag options to blanks, or click blank then click option'
Amessage
Bparams
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'message' or 'params' inconsistently causing key errors.
Confusing the keys for JSON parsing.