Menu locators

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

Menu locators

Postby mwa » Fri Jun 27, 2008 4:36 am

Hello,

with the recorder I record the following snippet:
Code: Select all
      ui.click(new MenuItemLocator("Edit/Find\\\\/Replace..."));

but that does not work:
Code: Select all
com.windowtester.runtime.WidgetNotFoundException: com.windowtester.swt.WidgetNotFoundException: Widget NOT Found:
Hierarchy matcher (Composite matcher with 2 component matchers:
[0] Exact Class matcher (org.eclipse.swt.widgets.MenuItem)
[1] Name Or Label matcher (Find\\/Replace...)
, Instance matcher (Menu {*Wrong Thread*})) in shell: Shell {XXX}
   at com.windowtester.swt.WidgetNotFoundException.getAdapter(WidgetNotFoundException.java:40)
   at com.windowtester.internal.runtime.selector.ClickHelper.doClick(ClickHelper.java:181)
   at com.windowtester.internal.runtime.selector.ClickHelper.click(ClickHelper.java:65)
   at com.windowtester.internal.runtime.UIContextCommon.click(UIContextCommon.java:83)
   at com.windowtester.runtime.swt.internal.UIContextSWT.click(UIContextSWT.java:286)
   at com.windowtester.internal.runtime.UIContextCommon.click(UIContextCommon.java:76)
   at com.windowtester.runtime.swt.internal.UIContextSWT.click(UIContextSWT.java:294)
   at com.windowtester.internal.runtime.UIContextCommon.click(UIContextCommon.java:69)
   at com.windowtester.runtime.swt.internal.UIContextSWT.click(UIContextSWT.java:277)
   at com.mycompany.mypackage.myTest(myTest.java:254)
   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:26)
   at com.windowtester.runtime.common.UITestCaseCommon$1.run(UITestCaseCommon.java:133)
   at com.windowtester.runtime.common.UITestCaseCommon$2.run(UITestCaseCommon.java:150)
   at com.windowtester.internal.runtime.junit.core.SequenceRunner$1.run(SequenceRunner.java:46)
Caused by: com.windowtester.swt.WidgetNotFoundException: Widget NOT Found:
Hierarchy matcher (Composite matcher with 2 component matchers:
[0] Exact Class matcher (org.eclipse.swt.widgets.MenuItem)
[1] Name Or Label matcher (Find\/Replace...)
, Instance matcher (Menu {*Wrong Thread*})) in shell: Shell {XXX}
   at com.windowtester.event.selector.swt.MenuItemSelector.resolveAndClick(MenuItemSelector.java:174)
   at com.windowtester.event.selector.swt.MenuItemSelector.click(MenuItemSelector.java:142)
   at com.windowtester.event.selector.swt.MenuItemSelector.click(MenuItemSelector.java:107)
   at com.windowtester.runtime.swt.locator.MenuItemLocator.click(MenuItemLocator.java:89)
   at com.windowtester.internal.runtime.selector.ClickHelper.doClick(ClickHelper.java:178)
   ... 18 more



Why is this "Wrong Thread" message? The line in which the exception occurs is that one mentioned above. When I omit the line, the rest of the test works. Commands like
Code: Select all
      ui.click(new MenuItemLocator("Edit/Select All"));
works as expected.

I also tried:
Code: Select all
ui.click(new MenuItemLocator("Edit/Find\\/Replace..."));
or
Code: Select all
ui.click(new MenuItemLocator("Edit/Find/Replace..."));
with the same result.
I am clueless now.

Michael
mwa
 
Posts: 24
Joined: Mon Jun 16, 2008 4:38 am

Re: Menu locators

Postby mwa » Fri Jun 27, 2008 4:54 am

Yeah, I found a workaround:
Code: Select all
      ui.keyClick(SWT.CTRL, 'F');
:D
Nonetheless it would be interesting why selecting with the menu entry seems not to work(at least for me).

Michael
mwa
 
Posts: 24
Joined: Mon Jun 16, 2008 4:38 am

Re: Menu locators

Postby Phil Quitslund » Fri Jun 27, 2008 7:24 am

Hi Michael,

I just confirmed that this is a bug. I've opened a ticket to schedule a fix. Thanks for the catch!


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

Re: Menu locators

Postby Phil Quitslund » Fri Jul 11, 2008 8:40 am

We fixed this one in our latest beta (07/11/2008).

From the history:

Runtime handling of Menu Items w/ Slashes (and Shortcuts) - The MenuItem path tokenizer has been fixed to handle corner cases with slashes (e.g., "Find/Replace...") and accelerators/shortcuts.


Let us know if you continue to have problems and thanks again for the catch!
--
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