Practice - 5 Tasks
Answer the questions below
1fill in blank
easyComplete 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'
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.
✗ Incorrect
The correct method to start performance logging is start_log('performance').
2fill in blank
mediumComplete 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'
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'browser' or 'network' which are different log types.
Using 'driver' which is not a valid log type.
✗ Incorrect
To get performance logs, use get_log('performance').
3fill in blank
hardFix 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'
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'messageText' or 'log' which do not exist in the log entry.
Using 'message' with wrong capitalization.
✗ Incorrect
The correct key to access the JSON string in each log entry is 'message'.
4fill in blank
hardFill 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'
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'params' instead of 'method' as the key.
Using 'Network.requestWillBeSent' which is a different event.
✗ Incorrect
Filter logs where 'method' key equals 'Network.responseReceived' to get network events.
5fill in blank
hardFill 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'
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'message' or 'params' inconsistently causing key errors.
Confusing the keys for JSON parsing.
✗ Incorrect
The JSON string is under 'message', and the event details are under 'params'.