// To receive exceptions from js side in the development mode, we need set this to 'true'.
// However, as htmlunit dies after throwing the exception, we still want it to be 'false'
// for web mode.
webClient.getOptions().setThrowExceptionOnScriptError(developmentMode);
webClient.setOnbeforeunloadHandler(this);
webClient.setJavaScriptErrorListener(new JavaScriptErrorListener() {
@Override
public void loadScriptError(HtmlPage htmlPage, URL scriptUrl,
Exception exception) {
treeLogger.log(TreeLogger.ERROR,