mardi 7 avril 2015

How to test appended javascript on wicket ajaxBehavior on JUnit test?

I have a function that appends in onload() method some javascript to the AjaxRequestTarget.


I load it by



add(onload);


and onload is having code like



AjaxEventBehavior event = new AjaxEventBehavior("onload") {
@Override
protected void onEvent(final AjaxRequestTarget target) {
attachJavascriptBehavior(target);
}
};
return event;


attachJavascriptBehavior adds some javascript as text to the target.


I want to test it with WicketTester.


So far I know I can make calls like:



tester.executeAjaxEvent("some:path", "onclick");


and maybe same will apply somehow for the onload, too. I found I can then call



tester.assertRenderedPage(MyWebPage.class);


to test if page is rendered after the event (event tackles some content size), but even if I in browser get errors in console, this tests goes surprisingly through. How to catch that console.log has reported javascript errors?


Source:


How to test AjaxEventBehavior("onClick") for Apache Wicket radio button?


Aucun commentaire:

Enregistrer un commentaire