Monday, January 25, 2010

Selenium and GXT CheckboxListView

I recently updated my application to use a menu hooked up to a button in which I display a GXT CheckboxListView of stamp issues. The general idea is that when defining my stamp if there are flaws (I tend to avoid collecting these) I can check-off the flaws in a drop-down like list. I added some selenium tests to capture the correct functionality, and came a across a few interesting points I thought I'd share.
  1. GXT does not appear to let you set a constant on the checkbox, such that can you tie it back to an enumerated list easily. This meant I had to navigate to the text of interest (localized display value of the enum) and then proceed back in the DOM to get the input field such as the following:

    MENU_LOCATOR + //td[.='" + display_str + "']/../td/input[contains(@class,'x-view-item-checkbox')]
  2. For closing the menu, the best approach I found was to use the "Escape" key on the menu itself:

    selenium.keyDown(PICKER_LOCATOR, "\u0027");
    selenium.keyPress(PICKER_LOCATOR, "\u0027");
    selenium.keyUp(PICKER_LOCATOR, "\u0027");
  3. Setting the value of the checkbox turned out to be more than simply using click(). In order for the click to be registered with the underlying GXT models I also needed to emit a DOMActivate event on the checkbox:


Version Info
GXT: 2.1.0
GWT: 2.0.0

No comments: