Luckily we can manipulate these dialogues with Selenium to either accept (click Ok) or dismiss (click Cancel) the pop up allowing your test(s) to continue.
You can also get the text of an alert if you need to make assertions against it or send keystrokes to it.
var alertText = alert.Text;
// Dismiss the Alert
Here we are switching to the active alert on screen, committing the text of it to a variable and then accepting the alert. We do not need to find elements on the dialogue in order to interact with them as the alert is not HTML based.
After this interaction occurs, focus will automatically resume on the main browser so we do not need to switch back to the browser.