TableItemLocator, isSelected(ui)...

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

TableItemLocator, isSelected(ui)...

Postby Ali Anwar » Tue Mar 30, 2010 2:44 am

TableItemLocator tiloc = new TableItemLocator("Value");
tiloc.isSelected(ui);

Always return false even if TableItem is in selected state. It was working as expected with previous version.
Ali Anwar
 
Posts: 8
Joined: Wed Dec 02, 2009 9:31 pm

Re: TableItemLocator, isSelected(ui)...

Postby Phil Quitslund » Wed Mar 31, 2010 9:50 am

We are not able to reproduce this on our end. It is possible that this is a timing issue exposed by our sped up runtime. Could you try this style of assertion instead?

Code: Select all
ui.assertThat(tiloc.isSelected());

(Do note that as a general rule this is the preferred style of assertion since it is less prone to timing issues.)

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

Re: TableItemLocator, isSelected(ui)...

Postby jyotisaxena » Fri Dec 03, 2010 4:50 am

Hi Phil,
I am also facing similar issue. I am trying to unselect one of the general eclipse preferences, which may or may not be already selected. But the TableItemLocator instance.isSelected(ui) is always returning false. Even though it is already selected, the assertion (ui.assertThat(tableItemLocator.isSelected(ui)))fails, ui.ensureThat(tableitemLocator.hasFocus()) results waitTimeOutException. Some help please.
jyotisaxena
 
Posts: 12
Joined: Mon Nov 08, 2010 11:04 am

Re: TableItemLocator, isSelected(ui)...

Postby keertip » Mon Dec 06, 2010 10:00 am

Could you post the test code? Thanks!
keertip
Moderator
 
Posts: 221
Joined: Thu Mar 15, 2007 10:26 am

Re: TableItemLocator, isSelected(ui)...

Postby jyotisaxena » Thu Dec 09, 2010 2:50 pm

Hi Phil,
This is the sample code which isn't working at line: cvsLocator.isSelected(ui)

public static void uncheckCVSDecorations(IUIContext ui) throws Exception {
ui.click(new MenuItemLocator("Window/Preferences"));
ui.wait(new ShellShowingCondition("Preferences"));
ui.click(new FilteredTreeItemLocator("General"));
ui.click(new FilteredTreeItemLocator(
"General/Appearance/Label Decorations"));
TableItemLocator cvsLocator = new TableItemLocator("CVS");
//Following condition is always true, hence the selection toggles.
if(!cvsLocator.isSelected(ui)){
ui.click(1,cvsLocator, WT.CHECK);
}
ui.click(new ButtonLocator("OK"));
ui.wait(new ShellDisposedCondition("Preferences"));
}
jyotisaxena
 
Posts: 12
Joined: Mon Nov 08, 2010 11:04 am

Re: TableItemLocator, isSelected(ui)...

Postby keertip » Fri Dec 10, 2010 9:59 am

The tableItem.isSelected(ui) looks to see whether the item has been selected, and not if the item is checked, as in the case of a checked table item.
To find out whether the table item is checked, you can do the following

Code: Select all
      TableItemLocator cvsLocator = new TableItemLocator("CVS");
      IWidgetReference ref = (IWidgetReference) ui.find(cvsLocator);
      final Widget widget = (Widget) ref.getWidget();
      final boolean[] result = new boolean[1];
      Display.getDefault().syncExec(new Runnable() {
         @Override
         public void run() {
            if (widget instanceof TableItem){
               TableItem item = (TableItem) widget;
               result[0] = item.getChecked();
            }
         }
      });
      if(!result[0]){
         ui.click(1,cvsLocator, WT.CHECK);
      }
keertip
Moderator
 
Posts: 221
Joined: Thu Mar 15, 2007 10:26 am

Re: TableItemLocator, isSelected(ui)...

Postby jyotisaxena » Tue Dec 14, 2010 5:42 am

Thanks.
jyotisaxena
 
Posts: 12
Joined: Mon Nov 08, 2010 11:04 am

Re: TableItemLocator, isSelected(ui)...

Postby keertip » Tue Dec 14, 2010 8:11 am

Great! Good to know that worked out.
keertip
Moderator
 
Posts: 221
Joined: Thu Mar 15, 2007 10:26 am

Re: TableItemLocator, isSelected(ui)...

Postby fredg » Wed Jan 12, 2011 7:12 am

Hi,

I was wondering why TableItemLocators and TreeItemLocators do not implement an isChecked() method.
Is there a good reason for it?

The workaround works, but it would be faster if the user could assert the checked state of TableItems and TreeItems with the inspection tool while recording.

Regards,

Fred
fredg
 
Posts: 7
Joined: Fri Nov 19, 2010 3:35 am

Re: TableItemLocator, isSelected(ui)...

Postby keertip » Wed Jan 12, 2011 8:30 am

There is no good reason for not implementing this feature - it is on the list for future enhancements.
keertip
Moderator
 
Posts: 221
Joined: Thu Mar 15, 2007 10:26 am

Re: TableItemLocator, isSelected(ui)...

Postby fredg » Wed Jan 12, 2011 9:49 am

Good to hear that it's already on the list. :D
Is there a rough timeframe for this enhancement?

Is it going to be mentioned in future release notes (of beta versions)?
fredg
 
Posts: 7
Joined: Fri Nov 19, 2010 3:35 am

Re: TableItemLocator, isSelected(ui)...

Postby keertip » Thu Jan 13, 2011 8:22 am

As of now, there is no time frame attached to the list. Will make a mention of it when it is done.
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