When testing web pages, you may need to capture an image of a web page or its object. For example, you may need to verify this image against a baseline copy or search for a smaller image. This topic explains how you can capture web page images while recording or editing your test or during the test run.
Note that the format in which TestComplete saves the captured images is specified by the Images property of your test project.
When recording a test, you can create a region checkpoint to capture the web page image and automatically insert test instructions that will compare this image with the actual image of the web page:
In the wizard, click Image.
Select the web page, the image of which you want to capture.
Specify comparison parameters and the comparison mask, if needed.
TestComplete will save the current image of the web page to the Regions collection and record a checkpoint that will verify the web page’s actual image against the stored one.
It is possible to capture web page images at design time and save them to the Stores | Regions collection of your project. To do this:
Right-click the Regions collection in the Project Explorer and select Add | New Item from the context menu.
– or –
Select New Item from the context menu of the Regions Editor.
The Add Image wizard appears.
Select Capture a window or region and click Next.
Select the web page, its object or area to capture and click Finish.
TestComplete will capture the image of the specified web page or object and automatically add it to the Regions collection. You can then make use of this object in your tests.
|Note:||The resulting screenshot only includes the visible page area. It does not include the page areas that are scrolled off the screen.|
To capture the web page image from a keyword test or script, call one of the following methods on the
Page object that corresponds to the web page:
Picture - Captures the visible part of the web page or its area.
PagePicture - Captures the entire web page image, including invisible areas that are scrolled off the screen.
|Note:||If your web page includes “sticky” elements (elements with a fixed position), for example, a navigation menu at the top of the page, use the
If the property is enabled (by default), the
If the property is disabled, the “sticky” elements will remain in the visible area of the page and, therefore, can re-appear on the resulting captured image several times.
To learn more, see the
Known Issue: The CSS transition may not work on pages opened in Internet Explorer or applications that use Chromium Embedded Framework versions prior to 3.2171. For such pages, elements with fixed positions may remain in the visible area of the page when scrolling, and the captured image will have those elements repeated.
Both methods return a
Picture object that corresponds to the captured image. You can use this object to save the underlying image to a file, compare it with another image, search for a subimage and perform other operations. For more information on comparing an finding images, see Alternatives to Region Checkpoints and Finding an Image Within Another Image.