Problem with TableItemLocator

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

Problem with TableItemLocator

Postby dkeysell » Thu May 28, 2009 8:21 am

I have recorded a test for a Wizard. The wizard contains only a single CheckboxTableViewer within the content area. The recorded test opens the Wizard, checks a checkbox in the first row of the CheckboxTableViewer and then selects Finish.

When I rerun the test it fails to check the checkbox. When running the recorded test it appears to try and select the checkbox in the first column following the checkbox column. Below is the exception I see on running the test. Here is line 46 of my test case (Hammer.java). I'm suspicious about the first paramter of the TableItemLocator (""), is there something else I should insert to represent a checkbox?:

ui.click(1, new TableItemLocator("", 0, new SWTWidgetLocator(
Table.class)));


com.windowtester.runtime.WaitTimedOutException: Timed out waiting for condition:
class=com.windowtester.runtime.condition.IsEnabledCondition
expected=true
actual=false
at com.windowtester.runtime.swt.internal.UIContextSWT.wait(UIContextSWT.java:775)
at com.windowtester.runtime.swt.internal.UIContextSWT.wait(UIContextSWT.java:747)
at com.windowtester.runtime.swt.locator.ButtonLocator.preClick(ButtonLocator.java:86)
at com.windowtester.runtime.swt.locator.SWTWidgetLocator.click(SWTWidgetLocator.java:225)
at com.windowtester.internal.runtime.selector.ClickHelper.doClick(ClickHelper.java:178)
at com.windowtester.internal.runtime.selector.ClickHelper.click(ClickHelper.java:65)
at com.windowtester.internal.runtime.UIContextCommon.click(UIContextCommon.java:87)
at com.windowtester.runtime.swt.internal.UIContextSWT.click(UIContextSWT.java:296)
at com.windowtester.internal.runtime.UIContextCommon.click(UIContextCommon.java:80)
at com.windowtester.runtime.swt.internal.UIContextSWT.click(UIContextSWT.java:304)
at com.windowtester.internal.runtime.UIContextCommon.click(UIContextCommon.java:73)
at com.windowtester.runtime.swt.internal.UIContextSWT.click(UIContextSWT.java:287)
at com.cisco.nm.xmp.sdk.cd.ui.internal.wizards.test.Hammer.testHammer(Hammer.java:46)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at junit.framework.TestCase.runTest(TestCase.java:164)
at junit.framework.TestCase.runBare(TestCase.java:130)
at com.windowtester.runtime.common.UITestCaseCommon.access$001(UITestCaseCommon.java:25)
at com.windowtester.runtime.common.UITestCaseCommon$2.run(UITestCaseCommon.java:136)
at com.windowtester.runtime.common.UITestCaseCommon$3.run(UITestCaseCommon.java:157)
at com.windowtester.internal.runtime.junit.core.SequenceRunner$1.run(SequenceRunner.java:46)

---------------------------------------------------------------------------------------------------------------------
When I added the following line to the test case I get the following error instead:

ui.find(new TableItemLocator("", 0, new SWTWidgetLocator(
Table.class)));

com.windowtester.runtime.WidgetNotFoundException: Widget NOT Found:
TableItemLocator(, 0, SWTWidgetLocator(org.eclipse.swt.widgets.Table))
at com.windowtester.runtime.swt.internal.UIContextSWT.find(UIContextSWT.java:608)
at com.windowtester.runtime.swt.internal.UIContextSWT.find(UIContextSWT.java:583)
at com.windowtester.runtime.swt.internal.UIContextSWT.find(UIContextSWT.java:583)
at com.windowtester.runtime.swt.internal.UIContextSWT.find(UIContextSWT.java:583)
at com.windowtester.runtime.swt.internal.UIContextSWT.find(UIContextSWT.java:583)
at com.windowtester.runtime.swt.internal.UIContextSWT.find(UIContextSWT.java:583)
at com.windowtester.runtime.swt.internal.UIContextSWT.find(UIContextSWT.java:583)
at com.windowtester.runtime.swt.internal.UIContextSWT.find(UIContextSWT.java:583)
at com.windowtester.runtime.swt.internal.UIContextSWT.find(UIContextSWT.java:583)
at com.windowtester.runtime.swt.internal.UIContextSWT.find(UIContextSWT.java:583)
at com.windowtester.runtime.swt.internal.UIContextSWT.find(UIContextSWT.java:583)
at com.cisco.nm.xmp.sdk.cd.ui.internal.wizards.test.Hammer.testHammer(Hammer.java:46)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at junit.framework.TestCase.runTest(TestCase.java:164)
at junit.framework.TestCase.runBare(TestCase.java:130)
at com.windowtester.runtime.common.UITestCaseCommon.access$001(UITestCaseCommon.java:25)
at com.windowtester.runtime.common.UITestCaseCommon$2.run(UITestCaseCommon.java:136)
at com.windowtester.runtime.common.UITestCaseCommon$3.run(UITestCaseCommon.java:157)
at com.windowtester.internal.runtime.junit.core.SequenceRunner$1.run(SequenceRunner.java:46)

-----------------------------------------------------------------------------------------------------------------------

I also inserted the following to check the Table was being located. The table is being located correctly.

WidgetReference ref = (WidgetReference)ui.find(new SWTWidgetLocator(Table.class));
Widget foundWidget = (Widget)ref.getWidget();
System.out.println(foundWidget.getClass);
dkeysell
 
Posts: 3
Joined: Thu May 28, 2009 6:03 am

Re: Problem with TableItemLocator

Postby Phil Quitslund » Thu May 28, 2009 8:47 am

Is this a multi-column table? Can you post a screenshot of the wizard at the time of failure?

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

Re: Problem with TableItemLocator

Postby dkeysell » Thu May 28, 2009 10:49 am

Yes it is a multi-column table. Here is a screenshot at the time of failure. The cursor was over the "com" of the second column.

Thanks
Attachments
Wizard-TableItemSelectionProblem.PNG
screenshot at time of failure
Wizard-TableItemSelectionProblem.PNG (156.67 KiB) Viewed 892 times
dkeysell
 
Posts: 3
Joined: Thu May 28, 2009 6:03 am

Re: Problem with TableItemLocator

Postby dkeysell » Thu May 28, 2009 11:47 am

I've found a solution to this, I needed to added WT.CHECK argument to the click call:

ui.click(1, new TableItemLocator("", 0, new SWTWidgetLocator(
Table.class)));

becomes
ui.click(1, new TableItemLocator("", 0, new SWTWidgetLocator(
Table.class)),WT.CHECK);

Thanks
dkeysell
 
Posts: 3
Joined: Thu May 28, 2009 6:03 am

Re: Problem with TableItemLocator

Postby Phil Quitslund » Mon Jun 01, 2009 7:18 am

Great. Thanks for sharing your solution!

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

Re: Problem with TableItemLocator

Postby ChrisEllsworth » Tue Dec 07, 2010 11:11 am

I've been working with a similar dialog. The column setup is the same as the screen shot. In my case I have a bunch of rows and I'm trying to select the row using the 2nd column. So it would be doing a single click on "com.cicco.xmp".

The previous answer
ui.click(1, new TableItemLocator("", 0, new SWTWidgetLocator(Table.class)),WT.CHECK);
uses the row index as the selection criteria.

I am trying to find a way to select check box using a locator that references the name/groupID text in the 2nd column.

Any ideas?

Chris
ChrisEllsworth
 
Posts: 4
Joined: Wed Mar 10, 2010 5:12 pm

Re: Problem with TableItemLocator

Postby keertip » Mon Dec 13, 2010 9:38 am

Hmm.... there is no quick way to do this, as we do not have a way of indicating the second column text in a TableItemLocator. You would need to do a ui.findall and then go through all the tableitems found to match them with the required column text.
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