课程: Test Automation with Selenium WebDriver for Java
免费学习该课程!
今天就开通帐号,24,700 门业界名师课程任您挑!
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…
内容
-
-
-
-
-
-
-
-
(已锁定)
Browser information1 分钟 17 秒
-
(已锁定)
Navigation1 分钟 44 秒
-
(已锁定)
Tabs3 分钟 24 秒
-
(已锁定)
Modals2 分钟 21 秒
-
(已锁定)
Alerts4 分钟 8 秒
-
(已锁定)
iFrames2 分钟 3 秒
-
(已锁定)
Cookies3 分钟 6 秒
-
(已锁定)
Taking screenshots7 分钟 35 秒
-
(已锁定)
Code Challenge: Accept alert in new tab37 秒
-
(已锁定)
Solution: Accept alert in new tab39 秒
-
(已锁定)
-
-
-