3.26.  Text - in Page Sections


You might find that a certain text exists more than once on a page, but only one of the occurrences has to be tested. This requires you to narrow the search to a section of a page. The syntax is simple:

<!-- Compare text inside a clipping area: -->

<testcase name="..">
  <assertThat testDocument="..">
    <hasText on=".." >
      <inClippingArea upperLeftX=".." upperLeftY=".." width=".." height=".." >
        ... <!-- compare text here -->


The following example shows the definition and the usage of a clipping area:

<testcase name="hasTextOnFirstPage_MultipleValidations">
  <assertThat testDocument="content/documentForTextClipping.pdf">
    <hasText on="FIRST_PAGE" >
      <inClippingArea upperLeftX="50" upperLeftY="130" width="170" height="25" > 1
        <containing>on first</containing>


This defines a clipping area. More detailed information is available in chapter 13.6: “Defining Page Areas”. The possibility to use measuring units such as MILLIMETER is described in chapter 13.7: “Format Units”.

When comparing text in page areas, all the test are available which are available when comparing text on entire pages. These tags are described in chapter 13.3: “Comparing Text”.

A clipping area can also be used when testing images.