Handle Multiple Browser Tabs and Alerts with Selenium WebDriver
In this tutorial, we will learn to handle multiple browser tabs within a single Selenium script. Selenium WebDriver does not provide any commands for this task. But we can make use of the existing Selenium commands in a smarter way to automate this scenario. Although this scenario is quite rare and you will not encounter it usually. 1. Handle Multiple Browser Tabs with Selenium Use Selenium Actions Class to Handle Multiple Browser Tabs Actions Class in Selenium is a special class which provides us very useful commands, which helps us to replicate Keyboard and Mouse events i.e., press/release any Key, move cursor, drag and drop, right click, double click etc. You can learn about Actions Class in detail here . In our scenario, we'll make use of Key control commands of Actions class to automate open and automate multiple browsers. Let's understand the whole code logic step by step. 1.1. Launch google.com with Selenium WebDriver This is the most common part, we'll launc