views:

116

answers:

1

This question is for the UISpec4J testing framework, for testing Java GUIs...

I'm trying to test an error message pop-up window (modal) that results from making a selection from a ComboBox, but I'm not sure how to return a Trigger object from the select action.

Here's a snippet:

WindowInterceptor
    .init(window.getComboBox("ComboBoxName").select("Choice that will cause error message")) // Problem here
    .process(new WindowHandler() {
     public Trigger process(Window errorMessage) {
      // Do stuff...
     }
    })
    .run();

In the .init() line, I'm supposed to return a Trigger object (like button.triggerClick()), but I don't know how to do that from a ComboBox selection.

Can someone please tell me how to return a trigger from a ComboBox selection?

Thanks for any help!

A: 

Couldn't you do something like:

 WindowInterceptor
    .init(new Trigger() {
        public void run() throws Exception {
            window.getComboBox("ComboBoxName").select("Choice that will cause erromessage");
        })
    .run();

It looks messy but it is an option to extract to make it read nicer. Please note this is untested, it's just what I would expect to do.

Grundlefleck
Yup, that did it.Thanks so much!
Bassam