0

Here's my scenario. I'm testing a Wicket app, and I'm parsing the page text wicktetTester.getServletResponse.getDocument as XML in order to find components with XPath. This is quite expensive, so I'd like to keep the dom4j.Document until the page changes, then rebuild it.

I know the current page - wicketTester.getLastRenderedPage but if I for example submit a form and stay on the same page, the Page object is the same object. What property of the page can I query to know that it has been re-rendered and that I need to rebuild my DOM?

public Document getDocument() {
   if (tester.getLastRenderedPage() != lastPageParsed && SOME_OTHER_TEST) {
       cachedDocument = parse(tester.getServletResponse().getDocument();
       lastPageParsed = tester.getLastRenderedPage();
   }
   return cachedDocument;
}
Duncan McGregor
  • 17,665
  • 12
  • 64
  • 118
  • _but if I for example submit a form and stay on the same page, the Page object does not change_ Generally this isn't true. When you submit a form, the current page is re-rendered. Whether the result is the same HTML output or not depends on your page. – biziclop Jul 03 '11 at 19:59
  • Depends on your definition of change - the object identity or state - I've clarified the question - the `Page` remains the same object, but its state changes. I want to know if the state is different without re-rendering. – Duncan McGregor Jul 03 '11 at 21:37

1 Answers1

0

Better see TagTester. I guess it will serve you better than XPath.

martin-g
  • 17,243
  • 2
  • 23
  • 35
  • I wish it did, but I can't see how. It isn't checking the tags that's the problem - its finding them. My GUI has a form with a table where a column may contain multiple checkboxes. The id-paths to find a component just get crazy - `order-panel:form:table:body:rows:1:cells:18:cell:listview:0:site-checkbox:checkbox`. With XPath I can use for example `//(input[@type="checkbox"])[3]` to get the third checkbox on the page. – Duncan McGregor Jul 03 '11 at 21:45