Cannot find swing button

WindowTester allows you to easily create and run unit tests for every GUI they build. It can also be used to generate system level tests.

Moderators: gnebling, Eric Clayberg, Dan Rubel, keertip, Phil Quitslund

Cannot find swing button

Postby jake.mccormick » Mon Nov 30, 2009 9:10 am

In WindowTester version 4.0, we are trying to select a swing button on an SWT dialog. We have named the button with setName("removeButton"). Using the WindowTester recorder gave us no code when clicking on this swing button. Our first attempt at using a Swing widget locator looks something like this (the arrowed line). The previous four lines were an additional attempt to use mouse hover to possibly get the button click to succeed.

ui.mouseMove(new XYLocator(new NamedWidgetLocator("SAComposite"), 200, 200));
ui.mouseMove(new XYLocator(new NamedWidgetLocator("SAComposite"), 100, 100));
ui.pause(5000);
IUIContext uiSwing = (IUIContext) ui.getAdapter(UIContextSwing.class);
----> uiSwing.click(new com.windowtester.runtime.swing.locator.NamedWidgetLocator("removeButton"));

This results in the following error:

com.windowtester.runtime.WidgetNotFoundException: Component not found NamedWidgetLocator("removeButton"):

The button does not have a label, only an image.

Any experience selecting Swing buttons with WindowTester 4.0 would be greatly appreciated.
jake.mccormick
 
Posts: 1
Joined: Mon Nov 30, 2009 8:55 am

Re: Cannot find swing button

Postby keertip » Tue Dec 01, 2009 8:16 am

You are on the right track. Currently the recorder does not support interactions with embedded swing components, so these actions have to be added in manually. In WT 4.0 we have simplified interactions with embedded swing components, in that you no longer need to explicitly get a swing UIContext. One can pass a Swing locator to a swt UIContext.
So instead of

Code: Select all
IUIContext uiSwing = (IUIContext) ui.getAdapter(UIContextSwing.class);
uiSwing.click(new com.windowtester.runtime.swing.locator.NamedWidgetLocator("removeButton"));

use
Code: Select all
ui.click(new com.windowtester.runtime.swing.locator.NamedWidgetLocator("removeButton"));

Try this and see if it works.
keertip
Moderator
 
Posts: 221
Joined: Thu Mar 15, 2007 10:26 am


Return to Window Tester

Who is online

Users browsing this forum: No registered users and 1 guest