NamedWidgetLocator

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

NamedWidgetLocator

Postby hyshyshys » Tue Apr 07, 2009 12:05 pm

Hi,

Sorry for this simple question, but I didn't find any answer or example in the documentation...

I'm using NamedWidgetLocator to locate widgets on dialogs and I want to know what is the best way to get the corresponding ButtonLocator, ComboLocator, ... locators to use the implemented interfaces provided by each sub classes of SWTWidgetLocator.

Suppose for example, that I know that my NamedWidgetLocator should locate a button :
1- How could I call the isSelected method provided by the IsSelected interface implemented by the ButtonLocator class? or I could I get a buttonLcator instance using the NamedWidgetLocator?

Code: Select all
NamedWidgetLocator widgetLocator = new NamedWidgetLocator("widgetName");
ButtonLocator buttonLocator = widgetLocator.??????
ui.assertThat(buttonLocator.isSelected());


2- Should I use the getAdapters methods to retrieve the IsSelected interface ? How?
Code: Select all
// Example that doesn't work
IsSelected selectableItem = (IsSelected) widgetLocator .getAdapter(IsSelected.class);


3- Could I use the IsSelectedCondition with NamedWidgetLocator ? How?

Vincent
hyshyshys
 
Posts: 37
Joined: Thu Jul 03, 2008 12:27 pm

Re: NamedWidgetLocator

Postby Phil Quitslund » Wed Apr 08, 2009 10:29 am

Hi Vincent,

This is a great question. The ability to do this is not quite complete. Could you send a note to support so we can work to get you a beta with a fix?

wintest-support@instantiations.com

Thanks!
--
Phil Quitslund
Software Engineer
Google, Inc.
Phil Quitslund
Moderator
 
Posts: 491
Joined: Fri Apr 28, 2006 6:26 am

Re: NamedWidgetLocator

Postby hyshyshys » Wed Apr 08, 2009 12:17 pm

Hi Phil,

I found a solution to this question but the solution is not very clean from my point of view. It makes my tests not very "clean".

Code: Select all
   // Get locator
   NamedWidgetLocator namedWidgetLocator = new NamedWidgetLocator("MyNamed");

   // Get widget reference
   IWidgetReference widgetReference = (IWidgetReference)ui.find(namedWidgetLocator);

   // Get widget
   Object widget = widgetReference.getWidget();
   assert !(widget instanceof Button);

   // Get button
   final Button button = (Button)widget;
   final boolean[] result = new boolean[1];
      
        // Create sync runnable to verify that the button is selected
   Display.getDefault().syncExec(new Runnable() {
      public void run() {
         result[0] = button.getSelection();
      }                     
   });
   boolean selection = result[0];



I will submit this question to support...
Thanks
hyshyshys
 
Posts: 37
Joined: Thu Jul 03, 2008 12:27 pm

Re: NamedWidgetLocator

Postby Phil Quitslund » Tue Apr 14, 2009 7:46 am

Thanks for posting your work-around and for following up with support.

We'll let you know when we have pushed a fix into a beta for you to try. Proper runtime support would definitely help to clean up your tests.
--
Phil Quitslund
Software Engineer
Google, Inc.
Phil Quitslund
Moderator
 
Posts: 491
Joined: Fri Apr 28, 2006 6:26 am

Re: NamedWidgetLocator

Postby hyshyshys » Thu Nov 12, 2009 9:36 am

Hi Phil,

Is this feature available right now?

Thanks

Vincent
hyshyshys
 
Posts: 37
Joined: Thu Jul 03, 2008 12:27 pm

Re: NamedWidgetLocator

Postby Phil Quitslund » Wed Nov 18, 2009 11:10 am

Hi Vincent,

Thanks for following up. These features are not in beta yet but we will drive our development with your input via the support ticket you submitted. We expect to have a beta for you to try in the next week.

-phil
--
Phil Quitslund
Software Engineer
Google, Inc.
Phil Quitslund
Moderator
 
Posts: 491
Joined: Fri Apr 28, 2006 6:26 am


Return to Window Tester

Who is online

Users browsing this forum: No registered users and 1 guest