课程: Test Automation with Selenium WebDriver for Java
免费学习该课程!
今天就开通帐号,24,700 门业界名师课程任您挑!
Taking screenshots
- [Instructor] Selenium WebDriver provides functionality to take screenshots within a browsing context, meaning the window, tab or frame where content is rendered. But before we can use this feature, we must enable WebDriver to create a bidirectional connection between our test script and the browser. This is done when instantiating our driver. So we can add a new option here, which is enableBiDi. Next, we'll set the browsing context to the window that we're on. So we'll say var BrowsingContext = new BrowsingContext and we'll pass in our driver instance and the context we want to set. In our case, let's set the context to the current window and we can do so by saying driver.getWindowsHandle. To capture a screenshot of the entire page, we say browsingContext.captureScreenshot. This returns a base 64 encoded string of the binary image data. So let's store this in a variable. Its type will be string and we can call this fullScreenshot. To view the screenshot as an image, we need to…
内容
-
-
-
-
-
-
-
-
(已锁定)
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 秒
-
(已锁定)
-
-
-