Prev |  | Next

# Chapter 6. Experience from Practice

## 6.1. Text in Page Header after Page 2

### Initial Situation

Say your company sends electronic invoices, and each page after the first page of the invoice should have a link to the home page of your company.

### Problem

The header of the first page differs from the header of the next pages. And the link itself is also given in the page body. That fact must not influence the test for the link in the header.

### Solution Approach

You have to define the relevant pages and also the region for the header. The following code shows how simple it is:

### Solution

    @Test
    public void hasLinkInHeaderAfterPage2() throws Exception {
      String filename = "documentUnderTest.pdf";
      String linkToHomepage = "http://pdfunit.com/";
      PagesToUse pagesAfter1 = ON_EVERY_PAGE.after(1);
      PageRegion headerRegion = createHeaderRegion();

      AssertThat.document(filename)
                .restrictedTo(pagesAfter1)
                .restrictedTo(headerRegion)
                .hasText()
                .containing(linkToHomepage)
      ;
    }

    private PageRegion createHeaderRegion() {
      int leftX  =   0;  // in millimeter
      int upperY =   0;
      int width  = 210;
      int height =  30;
      PageRegion headerRegion = new PageRegion(leftX, upperY, width, height);
      return headerRegion;
    }

Prev |  | Next
5.3. Validate all documents in a folder | Home | 6.2. Does Content Fit in Predefined Form Fields?