Quick Tour

blabno edited this page Jan 13, 2012 · 4 revisions
Clone this wiki locally

Quick Tour

This project aims to speed up development of tests that use HtmlUnit. It's done by caching WebClient instance and driving it with BeanShell console. Htmlunit-designer is meant to be to HtmlUnit as Firebug is to FireFox.

Features:

  • BeanShell console to drive web client
  • Current page source preview
  • List of requests
  • BeanShell expression watches //to be done
  • JavaScript watches //to be done

GUI

Main window is separated into sections:

  • Tabs (editor, current page source, request)
  • Request table (list of requests made by client)
  • BeanShell console

Tabs - editor

Inside editor you can write multiple instructions (separated by ; ) and execute them by hitting F5 or CTRL+Enter.

Tabs - current page source

This tab shows source of page returned by call to client.getCurrentWindow().getEnclosedPage().

Tabs - request

Shows details of request selected in "Request table".

Request table

Lists all requests executed by client.

BeanShell console

Console where you can type commands that are executed by BeanShell interpreter. Main goal of this console is to let you drive the client. By default you have WebClient instance available under "client" context variable. So in order to open a page with WebClient type:

p=client.getPage("http://somedomain.com");

You can instantiate new client like this:

otherClient=new com.gargoylesoftware.htmlunit.WebClient();

To make things easier we could import some classes:

import com.gargoylesoftware.htmlunit.*;

To print value of any expression type i.e.:

print(otherClient);

Multi-line console

By hitting "Switch layout" button in console window you can switch between single-line console and multi-line console. This is useful when you're focused on current page source tab but want to execute several commands at once. To execute instructions hit F5 or CTRL+Enter.

Multi-line console screenshot

Current page preview

Current page preview screenshot