โ† Back to libraryQuestion 152 of 273
๐ŸงชSeleniumIntermediate

Handling Pop-ups

๐Ÿ“– Detailed Explanation:

There are three types of pop-ups: 1. JavaScript Alerts/Confirmations (handled via `driver.switchTo().alert()`), 2. Web Pop-ups (just another window handle, switch using `switchTo().window()`), 3. OS Pop-ups (not handled by Selenium, require AutoIT or Robot class). JavaScript alerts can be accepted, dismissed, or have their text read using `.accept()`, `.dismiss()`, and `.getText()` methods.

๐ŸŒ Real-World Example:

JS Alert: A simple browser dialog managed by JavaScript. Web Pop-up: A new browser window/tab. OS Pop-up: A Windows dialog box that's outside the browser's control.

๐ŸŽฏ Scenario-Based Interview Question:

When you click 'Delete', a small box appears at the top of the browser saying 'Are you sure?'. You can't inspect this box. How do you click 'OK'?