课程: Test Automation with Selenium WebDriver for Java
免费学习该课程!
今天就开通帐号,24,700 门业界名师课程任您挑!
iFrames
- [Instructor] Iframes are web elements that allow a webpage to display content from another webpage. For example, this iframe has embedded click_iframe.html. Notice this iframe contains a link. Normally we would use WebDriver to locate this link in the DOM so that we can click it. However iframes include the DOM of the page that is embedded. So what we have here are two DOMs. In order to interact with an element within an iframe, we need to switch to the DOM within the frame. To switch to the iframe's context, we call driver.switchTo.frame. And we can pass in the iframe's ID or name to this method. The iframe's ID is ifr. If the iframe did not contain an ID or name attribute, you could also provide an index where zero is the top level DOM and the iframe's DOM would be at index one. Alternatively, you could use any locator strategy to find the iframe web element and pass that in. Okay, now we're in the DOM of the page that the iframe contains and can interact with any of its elements.…
内容
-
-
-
-
-
-
-
-
(已锁定)
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 秒
-
(已锁定)
-
-
-