From the course: Test Automation with Selenium WebDriver for Java
Unlock this course with a free trial
Join today to access over 25,300 courses taught by industry experts.
Tabs
From the course: Test Automation with Selenium WebDriver for Java
Tabs
- [Instructor] Clicking a link may open a new tab or window. Let's look at how Selenium Web driver allows us to navigate between multiple open web pages. After clicking the button, which opens a new window to get all of the open windows, we'll say var windows = driver.getWindowHandles(). This gives us a set of unique identifiers that represent each browser window or tab that is currently open within this session. In fact, let's print these out. So these handles allow you to switch control between the different tabs or windows that are open, but don't worry, you don't need to know these exact identifiers. Web driver provides convenience methods. For example, if we want to move the focus to the new tab we just opened, we can say driver.switchTo().window(), and we can provide the handle for the window, which we can get from our Windows collection. However, be careful because getWindowHandles() returns a set and this data structure does not guarantee order. So we cannot assume that the…
Contents
-
-
-
-
-
-
-
-
(Locked)
Browser information1m 17s
-
(Locked)
Navigation1m 44s
-
(Locked)
Tabs3m 24s
-
(Locked)
Modals2m 21s
-
(Locked)
Alerts4m 8s
-
(Locked)
iFrames2m 3s
-
(Locked)
Cookies3m 6s
-
(Locked)
Taking screenshots7m 35s
-
(Locked)
Code Challenge: Accept alert in new tab37s
-
(Locked)
Solution: Accept alert in new tab39s
-
(Locked)
-
-
-