Saving screenshots of an entire page

Some of the webpages exceed the height of the browser and require use of scrollbars to view the contents in the bottom of the page.

This influences creation of screenshots of the pages: concealed contents are not visible at the point of making a screenshot via the Picture method.

In this recipe we will learn how to create screenshots regardless of the dimensions of the window in the browser.

How to do it...

To create the screenshot of the whole of the webpage:

  1. Let's write a script to open the main page of the site of the SmartBear company:
    var br = Aliases.browser;
    br.ToUrl("http://smartbear.com");
    var page = br.pageMain;
  2. With the help of the PagePicture method we will save the screenshot of the page to the log:
    Log.Picture(page.PagePicture());
  3. If you launch the example, you will see the whole of the page saved to the log, including the section whose window-overflow parts were hidden.

How it works...

The method of PagePicture automatically scrolls the page making screenshots of its parts, and then automatically splices them to make a screenshot of the whole of the page.

Please note that, unlike the Picture method, the PagePicture method creates the screenshot of the page alone, and not that of the whole screen. This means: if there's a window on screen at the moment the screenshot is made (for example, an error alert that impacts work of the tested application), the screenshot will not show the window.

See also

  • More on screenshots creation could be learned from the Posting screenshots to the log recipe Chapter 6, Logging
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.144.15.43