Handling JavaScript Alerts, Confirmations, and Prompts
This lesson explains three native JavaScript popup messages provided by the WebDriver.
The below example code can be downloaded and run locally; it is included as a part of the Sample UI test framework, please refer.