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.
Modals
From the course: Test Automation with Selenium WebDriver for Java
Modals
- [Instructor] A modal is a popup window that when displayed, deactivates all other content on the page. Let's use Selenium WebDriver to engage with this modal. After clicking the button that triggers the modal, let's check if the modal is actually displayed. First, we'll find the modal by its ID, which is "modalContent". So we'll say WebElement modal = driver.findElement By.id, (keyboard keys clicking) and that ID is "modalContent". Then we'll say if the modal is displayed, and we can print a message. Let's say "modal is displayed". (keyboard keys clicking) Then we interact with the modal's elements just as we would with any other elements. The ID of the modal's text field is "modal-input". We can find that element and then send keys to type into it. So let's say: driver.findElement(By.id) "modal-input", and then we can call sendKeys(). And we can type anything in here, how about "hey modal". Great, and then to close the modal, we'll find the modal's close icon, which has an ID of…
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)
-
-
-