80 likes | 105 Views
HTMLUnit is a Java unit testing framework for simulating a web browser to check webpages. Learn installation steps, important functions, and differences from HttpUnit.
E N D
HtmlUnit Martin Liersch
Overview • What is HtmlUnit? • Difference to HttpUnit • Installation • Important functions
What is HtmlUnit? • „htmlunit is a java unit testing framework for testing webbased applications“ http://htmlunit.sourceforge.net/index.html • With htmlunit you can simulate a webbrowser and check the requested webpage. • Licencse: apache style license http://htmlunit.sourceforge.net/license.html
Difference to HttpUnit HttpUnit HtmlUnit Htmlunit models the requested webpage Htmlunit deals with the document: Pages Tables Frames Forms … • Httpunit models the http protocol • Httpunit deals with the http protocol: • http-requests • http-responses
Installation • Download HtmlUnit: http://downloads.sourceforge.net/htmlunit/htmlunit-1.10.zip • Extract it to any directory • Include it in your projects BuildPath
Important functions • WebClient: • Constructor: WebClient(BrowserVersion, ProxyServer) • getPage(String): Page, getPage(URL): Page • HtmlPage: • asText(): String, asXml(): String • getFormByName(String): HtmlForm/ getForms(): List • getFrameByName(String): FrameWindow / getFrames(): List • getHtmlElementById(String): HtmlElement • getTitleText(): String / setTitleText(String) • pressAccessKey(char)
Important functions • HtmlForm • getActionAttribute(): String • getId(): String • getInputByName(String): HtmlInput • getHtmlElementByTagName(String): HtmlElement • getOnSubmitAttribute(): String • setValueAttribute(String) • Submit()
Thanks for your attention. Anyquestions? Sources: http://htmlunit.sourceforge.net