A. send_keys called after accept, alert no longer available
B. Missing import for Alert class
C. Incorrect locator used for alert
D. No error, code works fine
Solution
Step 1: Understand alert lifecycle
Calling accept() closes the alert, so it cannot receive input afterward.
Step 2: Correct order for input and accept
send_keys() must be called before accept() to input text successfully.
Final Answer:
send_keys called after accept, alert no longer available -> Option A
Quick Check:
accept() closes alert, no send_keys after [OK]
Hint: Send keys before accept to avoid alert closed error [OK]
Common Mistakes:
Calling accept before send_keys
Ignoring alert closure after accept
Assuming alert object persists after accept
5. You want to test a prompt alert that asks for user age and rejects empty input. Which Selenium Python code correctly handles this scenario and verifies the rejection message?