HtmlUnit中屏蔽warnings

在使用HtmlUnit時會出現各種Warnings,如

七月 30,2013 10:21:36 上午 com.gargoylesoftware.htmlunit.IncorrectnessListenerImplnotify

WARNING: Expectedcontent type of 'application/javascript' or 'application/ecmascript' forremotely loaded JavaScript element at'http://person.sac.net.cn/js/library/Library.js', but got ''.

七月 30,2013 10:21:36 上午 com.gargoylesoftware.htmlunit.IncorrectnessListenerImplnotify

WARNING: Expectedcontent type of 'application/javascript' or 'application/ecmascript' forremotely loaded JavaScript element at'http://person.sac.net.cn/js/library/QueryLibrary.js', but got ''.

這些可以通過一些語句屏蔽掉:

        LogFactory.getFactory().setAttribute("org.apache.commons.logging.Log","org.apache.commons.logging.impl.NoOpLog");

 java.util.logging.Logger.getLogger("com.gargoylesoftware").setLevel(Level.OFF);

屏蔽掉異常:

    webClient.getOptions().setThrowExceptionOnScriptError(false);

    webClient.getOptions().setThrowExceptionOnFailingStatusCode(false);

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章