开发者

Can I get the source of the current Wicket Page?

I've been using wicketTester.getServetResponse.getDocument to get the text of the current page for testing, only to find that after an ajax request it is set to the ajax response, not the wh开发者_开发百科ole page.

Is there any way to get a representation of the whole rendered page, as the browser would be seeing it after the ajax manipulation?


With WicketTester, you can simulate an Ajax call and see that your app sends the correct Ajax response. But it doesn't really exercise the ajax.

So I don't believe there's a way to get that from WicketTester.

If you actually need to test the app all the way to the UI including Ajax/javascript effects on the rendering, you likely need to use something like Selenium for that portion of your testing.


Thinking the Wicket way I hope the following approach should work:

  1. #startPage(YourPage.class)
  2. do some Ajax calls
  3. #startPage(wicketTester.getLastRenderedPage())
  4. wicketTester.getLastRenderedPageAsString()

The idea is: you start a page for testing, the first response is complete page response, then you do some Ajax calls which change some models around, then you start the last rendered page as an instance - this way it will render the page with the updated models from the Ajax calls.


The trouble is that you can put any Javascript in the response to an Ajax call. But if you don't want to deal with that, you can save the original full-page DOM, iterate through the objects in the Ajax response, find them by id in the full DOM and replace them with the new versions.

How useful this would be, I don't know, my guess would be not very. so I'd probably go with Selenium too.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜