RWTBot

November 15, 2012 | 2 min Read

Recently I started working at a headless client for RAP 2.0 with the following aims:

  • Allow functional testing of RAP/RWT applications.
  • Allow stress testing of RAP/RWT applications, working together with a performance test library.

A secondary requirement is to:

  • Be similar enough to the SWTBot API so that the effort for testing single-sourced applications is minimal

which gives this project the name RWTBot.

The following example test connects to the RWT Controls Demo and tests the toggle button functionality:

@Test
public void selectToggleButton() throws Exception {
  String rwtAppUrl = "http://rap.eclipsesource.com/controlsdemo/controls";
  RWTBot bot = new RWTBot(new RWTBotClientParameters(rwtAppUrl));
  RWTBotDisplay session = bot.startSession(); // 1. handshake
  RWTBotShell shell = session.shell(); // 2. identify the main window
  RWTBotButton observed = shell.button("Toggle"); // 3. Find a button named "Toggle"
  assertFalse(observed.getSelection()); // 4. check precondition

  shell.button("Toggle Button").click(); // 5. trigger UI change

  assertTrue(observed.getSelection()); // 6. check post condition
}

During the test, this happens inside RWTBot:

  1. The initial handshake is executed with the RWT Demo. This opens a RAP session and a display is created. All widgets on the main screen are received. RWTBot control handlers for roughly 100 controls are created and configured.
  2. Initially there is just the main window. This is identified and the RWTBot handle is received.
  3. The main window has a button named “Toggle”. A handle for the button is received and remembered as a local variable. It will reflect the state change in the UI.
  4. Assert that the precondition is as expected, ie. that the toggle button is deselected.
  5. The “Toggle Button” is clicked. This is sent to the server which responds with changes for the UI. These changes include the activation of the observed button.
  6. Assert that the postcondition is as expected, ie. that the toggle button is activated.

Did I miss any design criteria for RWTBot? Are you interested in a working RWTBot? Leave a comment or email me to let us know.