我可以获得当前 Wicket 页面的来源吗?
我一直在使用 wicketTester.getServetResponse.getDocument 来获取当前页面的文本进行测试,结果发现在 ajax 请求之后它被设置为 ajax 响应,而不是整个页面。
有没有办法获得整个渲染页面的表示,因为浏览器在 ajax 操作后会看到它?
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 whole 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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
使用 WicketTester,您可以模拟 Ajax 调用并查看您的应用程序发送正确的 Ajax 响应。但它并没有真正锻炼ajax。
所以我不相信有办法从 WicketTester 获得它。
如果您实际上需要测试应用程序一直到 UI,包括 Ajax/javascript 对渲染的影响,您可能需要使用类似 的东西Selenium 用于您的测试部分。
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.
以 Wicket 方式思考,我希望以下方法应该有效:
想法是:启动一个页面进行测试,第一个响应是完整的页面响应,然后您执行一些 Ajax 调用来更改周围的一些模型,然后您启动最后渲染的页面作为实例 - 这样它将使用以下内容渲染页面通过 Ajax 调用更新模型。
Thinking the Wicket way I hope the following approach should work:
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.
问题在于您可以将任何 Javascript 放入对 Ajax 调用的响应中。但如果你不想处理这个问题,你可以保存原始的全页 DOM,迭代 Ajax 响应中的对象,通过完整 DOM 中的 id 找到它们,然后用新版本替换它们。
我不知道这有多大用处,我的猜测不是很有用。所以我可能也会选择 Selenium。
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.