ComboBox selection

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

ComboBox selection

Postby tvaseeharan » Tue Mar 13, 2007 1:28 pm

Is there a way to select an item from a combo box based on the label using WindowTester? I've been able to select the combo box item, but can't select an item.

Thank you.
tvaseeharan
 
Posts: 3
Joined: Mon Mar 12, 2007 3:43 pm

Postby Phil Quitslund » Tue Mar 13, 2007 4:01 pm

Could you post a code snippet? I'm not sure what you're trying to do... What do you my "by the label"?

In the simplest case,

Code: Select all
ui.click(new ComboItemLocator("item 1"));


should select the "item 1" item. Is this what you're trying to do?
--
Phil Quitslund
Software Engineer
Google, Inc.
Phil Quitslund
Moderator
 
Posts: 491
Joined: Fri Apr 28, 2006 6:26 am

Postby tvaseeharan » Tue Mar 13, 2007 4:50 pm

Yes, thats what I was looking for thanks. But now I am having an a different problem.

When use do the following I get a MultipleWidgetsFoundException

Code: Select all
ui.click(new ComboItemLocator("item1"));


So I did the following:

Code: Select all
Combo comboBox = new Combo(composite, SWT.READ_ONLY);
comboBox.setData("name", "combo.MyComboBox");
...
ui.click(new ComboItemLocator("item1", new NamedWidgetLocator("combo.MyComboBox")));


which produces the following:

Code: Select all
java.lang.IllegalArgumentException: Class must not be null
   at com.windowtester.internal.runtime.matcher.ExactClassMatcher.<init>(ExactClassMatcher.java:37)
   at com.windowtester.internal.runtime.matcher.ExactClassMatcher.<init>(ExactClassMatcher.java:27)
   at com.windowtester.runtime.swt.locator.InternalMatcherBuilder.build(InternalMatcherBuilder.java:51)
   at com.windowtester.runtime.swt.internal.locator.VirtualItemLocator.buildMatcher(VirtualItemLocator.java:111)
   at com.windowtester.runtime.swt.locator.SWTWidgetLocator.getMatcher(SWTWidgetLocator.java:161)
   at com.windowtester.runtime.swt.locator.SWTWidgetLocator.matches(SWTWidgetLocator.java:151)
   at com.windowtester.runtime.swt.internal.finder.matchers.SWTFinderMatcherAdapter.matches(SWTFinderMatcherAdapter.java:34)
   at com.windowtester.finder.swt.WidgetFinder.findMatches(WidgetFinder.java:324)
   at com.windowtester.finder.swt.WidgetFinder.findMatches(WidgetFinder.java:319)
   at com.windowtester.finder.swt.WidgetFinder.findMatches(WidgetFinder.java:319)
   at com.windowtester.finder.swt.WidgetFinder.findMatches(WidgetFinder.java:319)
   at com.windowtester.finder.swt.WidgetFinder.findMatches(WidgetFinder.java:319)
   at com.windowtester.finder.swt.WidgetFinder.findMatches(WidgetFinder.java:319)
   at com.windowtester.finder.swt.WidgetFinder.findMatches(WidgetFinder.java:319)
   at com.windowtester.finder.swt.WidgetFinder.find0(WidgetFinder.java:270)
   at com.windowtester.finder.swt.WidgetFinder.find(WidgetFinder.java:217)
   at com.windowtester.finder.swt.WidgetFinder.find(WidgetFinder.java:212)
   at com.windowtester.finder.swt.WidgetFinderService.collectMatches(WidgetFinderService.java:66)
   at com.windowtester.finder.swt.SWTWidgetFinder.findAll(SWTWidgetFinder.java:67)
   at com.windowtester.runtime.WidgetLocator.findAll(WidgetLocator.java:377)
   at com.windowtester.runtime.swt.internal.UIContextSWT.findAll(UIContextSWT.java:377)
   at com.windowtester.runtime.swt.internal.UIContextSWT.find(UIContextSWT.java:364)
   at com.windowtester.runtime.swt.locator.ComboItemLocator.click(ComboItemLocator.java:64)
   at com.windowtester.internal.runtime.selector.ClickHelper.click(ClickHelper.java:66)
   at com.windowtester.internal.runtime.UIContextCommon.click(UIContextCommon.java:71)
   at com.windowtester.runtime.swt.internal.UIContextSWT.click(UIContextSWT.java:219)
   at com.windowtester.internal.runtime.UIContextCommon.click(UIContextCommon.java:64)
   at com.windowtester.runtime.swt.internal.UIContextSWT.click(UIContextSWT.java:227)
   at com.windowtester.internal.runtime.UIContextCommon.click(UIContextCommon.java:57)
   at com.windowtester.runtime.swt.internal.UIContextSWT.click(UIContextSWT.java:210)
   at com.fnfr.svt.ui.tests.SampleTest.testMain(SampleTest.java:35)
   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:585)
   at junit.framework.TestCase.runTest(TestCase.java:154)
   at junit.framework.TestCase.runBare(TestCase.java:127)
   at junit.extensions.UITestCaseCommon.access$1(UITestCaseCommon.java:1)
   at junit.extensions.UITestCaseCommon$1.run(UITestCaseCommon.java:136)
   at junit.extensions.core.SequenceRunner$1.run(SequenceRunner.java:69)


I then tried this:

Code: Select all
Combo comboBox = new Combo(composite, SWT.READ_ONLY);
comboBox.setData("name", "combo.MyComboBox");
...
IWidgetLocator combo = ui.find(new NamedWidgetLocator("combo.MyComboBox"));
ui.click(new ComboItemLocator("item1", combo));


which didn't produce the exception; instead the test just hung w/o any messages in the console.


Hopefully you can help with this issue as well. Thanks again for all your help.
tvaseeharan
 
Posts: 3
Joined: Mon Mar 12, 2007 3:43 pm

Postby Phil Quitslund » Wed Mar 14, 2007 5:29 am

Aha! Well, this looks like a bug for sure. Please send a report to wintest-support@instantiations.com

(Copying what you wrote below would be perfect.)

We'll track it and fix it there.

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

Postby Phil Quitslund » Thu Mar 15, 2007 8:29 am

Thanks again for catching this. We should promote a beta next week that will include a fix.
--
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