Recall & Review
beginner
What is a simple alert in Selenium?
A simple alert is a popup box that shows a message and has only an OK button. It requires user action to accept it before continuing.
Click to reveal answer
beginner
How do you switch to a simple alert in Selenium with Python?
Use
driver.switch_to.alert to focus on the alert popup so you can interact with it.Click to reveal answer
beginner
Which method accepts (clicks OK) on a simple alert in Selenium Python?
The method
accept() is used on the alert object to click the OK button and close the alert.Click to reveal answer
beginner
Write a simple Selenium Python code snippet to accept an alert.
alert = driver.switch_to.alert
alert.accept()
This switches to the alert and clicks OK to accept it.
Click to reveal answer
beginner
Why is it important to accept alerts in automated tests?
Because alerts block the browser until handled, tests will stop or fail if alerts are not accepted. Handling alerts keeps tests running smoothly.
Click to reveal answer
What does
driver.switch_to.alert do in Selenium?✗ Incorrect
This command switches the driver's focus to the alert popup so you can accept or dismiss it.
Which method clicks the OK button on a simple alert?
✗ Incorrect
The
accept() method clicks the OK button on the alert.What happens if you do not accept a simple alert in Selenium?
✗ Incorrect
Alerts block the browser until accepted or dismissed, so tests will pause or fail if not handled.
Which of these is the correct way to accept an alert in Selenium Python?
✗ Incorrect
You must first switch to the alert, then call
accept() on it.What type of alert has only an OK button?
✗ Incorrect
A simple alert shows a message and has only an OK button.
Explain how to handle a simple alert in Selenium Python.
Think about how you focus on the alert and then accept it.
You got /3 concepts.
Write a short code snippet to accept a simple alert in Selenium Python.
Use two lines: one to switch, one to accept.
You got /2 concepts.