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.


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:


public void hasLinkInHeaderAfterPage2() throws Exception {
  String filename = "documentUnderTest.pdf";
  String linkToHomepage = "";
  PagesToUse pagesAfter1 = ON_EVERY_PAGE.after(1);
  PageRegion headerRegion = createHeaderRegion();

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;