Home » Archived » Test and Performance Tools Platform (TPTP) » Cannot locate menu item 
| Cannot locate menu item [message #116716] | 
Tue, 30 October 2007 02:54   | 
 
Eclipse User  | 
 | 
 | 
   | 
 
Hi All, 
 
Ive recoded an AGR test case where a PreferenceDialog is spawned from a  
top level menu and new pages are added from the right-click menus(my  
dialog has pop-up menus in the right hand side). Now when I run the AGR  
test case it opens the PreferenceDialog after that it throws error  
messages. 
 
Any idea why this is happening?  
 
org.eclipse.core.runtime.CoreException 
Line 15: Cannot locate menu item: {{New}}-{{1.0}} 
org.eclipse.core.runtime.CoreException: Line 15: Cannot locate menu item:  
{{New}}-{{1.0}} 
  at  
 org.eclipse.tptp.test.auto.gui.internal.AutoGUIUtil.throwCor eException(AutoGUIUtil.java:616) 
  at  
 org.eclipse.tptp.test.auto.gui.internal.AutoGUIUtil.throwCor eException(AutoGUIUtil.java:608) 
  at  
 org.eclipse.tptp.test.auto.gui.internal.macro.MacroObjectLoc ator.locatePopupMenuItem(MacroObjectLocator.java:432) 
  at  
 org.eclipse.tptp.test.auto.gui.internal.macro.MacroObjectLoc ator.locateCommandTarget(MacroObjectLocator.java:92) 
  at  
 org.eclipse.tptp.test.auto.gui.internal.commands.BooleanSele ctionCommand.playback(BooleanSelectionCommand.java:258) 
  at  
 org.eclipse.tptp.test.auto.gui.internal.commands.MacroComman dShell$4.run(MacroCommandShell.java:1160) 
  at  org.eclipse.swt.widgets.RunnableLock.run(RunnableLock.java:3 5) 
  at  
 org.eclipse.swt.widgets.Synchronizer.runAsyncMessages(Synchr onizer.java:123)
 |  
 |  
  |   |  
| Re: Cannot locate menu item [message #121700 is a reply to message #117318] | 
Fri, 01 February 2008 04:44    | 
 
Eclipse User  | 
 | 
 | 
   | 
 
Hi Paul, 
 
As per the description I has added the following entry in the widgetReg.xml 
 
 <class name = "org.eclipse.swt.widgets.Text" matchThreshold = "1.0"> 
  <method name = "getData" weight = "1.0"> 
    <argument value = "menu.new"/> 
  </method> 
 </class> 
  <class name = "org.eclipse.swt.widgets.Text" matchThreshold = "1.0"> 
  <method name = "getData" weight = "1.0"> 
    <argument value = "menu.delete"/> 
  </method> 
 </class> 
 
I has changed my pop-up menu's code in pereference dialog like , 
 
public void handleEvent(Event event) { 
		    	 
    	Menu menu = new Menu(_dialog.getShell(), SWT.POP_UP); 
    	 
    	MenuItem newItem = new MenuItem(menu, SWT.PUSH); 
    	newItem.setText("New"); 
    	newItem.setData("menu.new", "MyNew"); 
        newItem.addSelectionListener(new PopUpListener()); 
         
        MenuItem deleteItem = new MenuItem(menu, SWT.PUSH); 
        deleteItem.setText("Delete"); 
        deleteItem.setData("menu.delete", "MyDelete"); 
        deleteItem.addSelectionListener(new PopUpListener()); 
          
        menu.setLocation(event.x, event.y); 
        menu.setVisible(true); 
    } 
     
    then I has recorded same use case. But my AGR script is looks like  
same. As per my understanding widget id should be save like this, 
<command descriptive="New" type="select"  
resolverId="org.eclipse.tptp.test.auto.gui.nontrivial"  
contextId="popup/shell/org.eclipse.swt.widgets.Tree#1"  
widgetId="{{MyNew}}-{{1.0}}"/> 
 
But AGR script is saved like this, 
<command descriptive="New" type="select"  
resolverId="org.eclipse.tptp.test.auto.gui.nontrivial"  
contextId="popup/shell/org.eclipse.swt.widgets.Tree#1"  
widgetId="{{New}}-{{1.0}}"/> 
 
I am not able continue my work because of this issue. Please help me ro  
resolve this. 
 
 
Thanks, 
Pushparaj.
 |  
 |  
  |  
| Re: Cannot locate menu item [message #121713 is a reply to message #121700] | 
Fri, 01 February 2008 06:50    | 
 
Eclipse User  | 
 | 
 | 
   | 
 
Originally posted by: any.swc.rwth-aachen.de 
 
I think the class name should be org.eclipse.swt.widgets.MenuItem instead of  
org.eclipse.swt.widgets.Text, if you want to resolve MenuItems. 
 
Regards 
Alexander 
 
 
"Pushparaj" <pushparaj_94@yahoo.com> schrieb im Newsbeitrag  
news:d36084abb2a5330e20bd3bf6bffef72c$1@www.eclipse.org... 
> Hi Paul, 
> 
> As per the description I has added the following entry in the  
> widgetReg.xml 
> 
> <class name = "org.eclipse.swt.widgets.Text" matchThreshold = "1.0"> 
>  <method name = "getData" weight = "1.0"> 
>    <argument value = "menu.new"/> 
>  </method> 
> </class> 
>  <class name = "org.eclipse.swt.widgets.Text" matchThreshold = "1.0"> 
>  <method name = "getData" weight = "1.0"> 
>    <argument value = "menu.delete"/> 
>  </method> 
> </class> 
> 
> I has changed my pop-up menu's code in pereference dialog like , 
> 
> public void handleEvent(Event event) { 
>     Menu menu = new Menu(_dialog.getShell(), SWT.POP_UP); 
>    MenuItem newItem = new MenuItem(menu, SWT.PUSH); 
>    newItem.setText("New"); 
>    newItem.setData("menu.new", "MyNew"); 
>        newItem.addSelectionListener(new PopUpListener()); 
>        MenuItem deleteItem = new MenuItem(menu, SWT.PUSH); 
>        deleteItem.setText("Delete"); 
>        deleteItem.setData("menu.delete", "MyDelete"); 
>        deleteItem.addSelectionListener(new PopUpListener()); 
>         menu.setLocation(event.x, event.y); 
>        menu.setVisible(true); 
>    } 
>    then I has recorded same use case. But my AGR script is looks like  
> same. As per my understanding widget id should be save like this, 
> <command descriptive="New" type="select"  
> resolverId="org.eclipse.tptp.test.auto.gui.nontrivial"  
> contextId="popup/shell/org.eclipse.swt.widgets.Tree#1"  
> widgetId="{{MyNew}}-{{1.0}}"/> 
> 
> But AGR script is saved like this, 
> <command descriptive="New" type="select"  
> resolverId="org.eclipse.tptp.test.auto.gui.nontrivial"  
> contextId="popup/shell/org.eclipse.swt.widgets.Tree#1"  
> widgetId="{{New}}-{{1.0}}"/> 
> 
> I am not able continue my work because of this issue. Please help me ro  
> resolve this. 
> 
> 
> Thanks, 
> Pushparaj. 
> 
>
 |  
 |  
  |   |  
| Re: Cannot locate menu item [message #121810 is a reply to message #121700] | 
Sat, 02 February 2008 03:51    | 
 
Eclipse User  | 
 | 
 | 
   | 
 
Hi, Pushparaj, 
 
I think the way you modify the widgetReg.xml is incorrect first. 
 
As I understand, the "value" attribute of <argument> element should be  
the key of the getData()/setData() method. 
 
So if your menuItem is set as: 
 
newItem.setData("menu.key", "MyNew"); 
deleteItem.setData("menu.key", "MyDelete"); 
 
Then you can have the following lines in widgetReg.xml, for using the  
"menu.key" key's value to identify the menu item. 
<class name = "org.eclipse.swt.widgets.MenuItem" matchThreshold = "1.0"> 
  <method name = "getData" weight = "1.0"> 
    <argument value = "menu.key"/> 
  </method> 
</class> 
 
Then your recorded script will looks like 
 
<command descriptive="New" type="select" 
resolverId="org.eclipse.tptp.test.auto.gui.nontrivial" 
contextId="popup/shell/org.eclipse.swt.widgets.Tree#1" 
widgetId="MyNew"/> 
 
Your current recorded script are actually not resolved using the  
widgetReg.xml file. It is resolved by  
 org.eclipse.tptp.test.auto.gui.internal.resolvers.NonTrivial WidgetResolver.  
Only the  
 org.eclipse.tptp.test.auto.gui.internal.resolvers.AdaptiveWi dgetResolver  
uses the widgetReg.xml file. 
 
Regards, 
Jimmy Jin 
 
Pushparaj wrote: 
> Hi Paul, 
>  
> As per the description I has added the following entry in the widgetReg.xml 
>  
> <class name = "org.eclipse.swt.widgets.Text" matchThreshold = "1.0"> 
>  <method name = "getData" weight = "1.0"> 
>    <argument value = "menu.new"/> 
>  </method> 
> </class> 
>  <class name = "org.eclipse.swt.widgets.Text" matchThreshold = "1.0"> 
>  <method name = "getData" weight = "1.0"> 
>    <argument value = "menu.delete"/> 
>  </method> 
> </class> 
>  
> I has changed my pop-up menu's code in pereference dialog like , 
>  
> public void handleEvent(Event event) { 
>                 
>        Menu menu = new Menu(_dialog.getShell(), SWT.POP_UP); 
>        
>        MenuItem newItem = new MenuItem(menu, SWT.PUSH); 
>        newItem.setText("New"); 
>        newItem.setData("menu.new", "MyNew"); 
>        newItem.addSelectionListener(new PopUpListener()); 
>               MenuItem deleteItem = new MenuItem(menu, SWT.PUSH); 
>        deleteItem.setText("Delete"); 
>        deleteItem.setData("menu.delete", "MyDelete"); 
>        deleteItem.addSelectionListener(new PopUpListener()); 
>                menu.setLocation(event.x, event.y); 
>        menu.setVisible(true); 
>    } 
>       then I has recorded same use case. But my AGR script is looks like  
> same. As per my understanding widget id should be save like this, 
> <command descriptive="New" type="select"  
> resolverId="org.eclipse.tptp.test.auto.gui.nontrivial"  
> contextId="popup/shell/org.eclipse.swt.widgets.Tree#1"  
> widgetId="{{MyNew}}-{{1.0}}"/> 
>  
> But AGR script is saved like this, 
> <command descriptive="New" type="select"  
> resolverId="org.eclipse.tptp.test.auto.gui.nontrivial"  
> contextId="popup/shell/org.eclipse.swt.widgets.Tree#1"  
> widgetId="{{New}}-{{1.0}}"/> 
>  
> I am not able continue my work because of this issue. Please help me ro  
> resolve this. 
>  
>  
> Thanks, 
> Pushparaj. 
>  
>
 |  
 |  
  |   |  
| Re: Cannot locate menu item [message #121866 is a reply to message #121849] | 
Sun, 03 February 2008 09:47    | 
 
Eclipse User  | 
 | 
 | 
   | 
 
Hi, Pushparaj, 
 
I looked at the code you included in your message again, and I found  
something strange in your code. You have the menu created in a  
handleEvent method. What is this listener listening for? The mouse  
right-click? If it is the case, I think, even you can record the script,  
you still cannot playback it. 
 
The reason is that the way MacroObjectLocator uses for finding out the  
popup menu item is by using the Control.getMenu() method on all the  
controls on one Shell to get all the popup menus and then try to find  
out if any of them matches the desired one. Since your menu is  
dynamically created, maybe when the command is running, the menu hasn't  
been created, so it cannot be found. I'm not sure whether it can work,  
if you simulate a mouse click to make the menu created before select the  
menu. Or, if possible, you can change the mechanism to have the menu  
created statically and set to certain Control on the dialog. 
 
Maybe if you provide the script you recorded after the latest change to  
the widgetReg.xml, I can provide some more advise. 
 
Jimmy Jin 
 
Pushparaj wrote: 
> Hi Jimmy Jin, 
>  
> As per your reply I has changed my widgetReg.xml. Now the recorded  
> script is proper. but while running the script i am getting the same error. 
>  
>  
> Thanks, 
> Pushparaj.
 |  
 |  
  |   |  
| Re: Cannot locate menu item [message #122585 is a reply to message #122143] | 
Sun, 10 February 2008 06:40   | 
 
Eclipse User  | 
 | 
 | 
   | 
 
Hello, Pushparaj, 
 
After reading the script you recorded, I think I know your scenario more  
.. Here are some suggestions from me, which I think I will take if I do  
it by myself. 
 
1. When dynamically creating the popup menu, it MUST be set to certain  
Control, such as the Tree. It is for making sure that when playing back,  
  AGR can use the getMenu method to locate the menu. So I may add the  
following lines into the handleEvent method. 
 
Tree myTree = (Tree) event.widget; 
myTree.setMenu(menu); 
 
2. The mouse right-click event must be simulated and notify all the  
listeners of the event on the Tree, so that the menu gets created. There  
are 2 ways, in my mind, can achieve this. 
	a. Add a Verification Point before the popup menu selection command,  
and in the Verification Point, find out the Tree and send it a proper  
event with notifyListener method (or just call the handleEvent method  
directly). 
	b. Add a Position Based command before popup menu selection command. 
 
I'm not sure if this can help, since I haven't encountered this kind of  
case so far. 
 
Regards, 
Jimmy Jin 
 
Pushparaj wrote: 
> Hi Jimmy Jin, 
> Yes. I am creating menus in mouse right-click. 
> As per my requirement i should create menu itemes at  
> runtime(dynamically). So Pls give me some other solutions 
>  
> <macro version="1.0"> 
>     <shell descriptive="OpenClovis IDE - MyTestSuite1 - Eclipse SDK"  
> id="org.eclipse.ui.internal.WorkbenchWindow" return-code="-1"> 
>         <command descriptive="TestModel" type="item-select"  
> resolverId="org.eclipse.tptp.test.auto.gui.adaptive"  
> contextId="view/com.clovis.cw.workspace.clovisWorkspaceView "  
> widgetId="{{/}}-{{1.0}}"> 
>             <item path="{{/TestModel}}-{{1.0}}"  
> resolverId="org.eclipse.tptp.test.auto.gui.adaptive"/> 
>         </command> 
>         <command type="focus"  
> contextId="view/com.clovis.cw.workspace.clovisWorkspaceView "  
> widgetId="org.eclipse.swt.widgets.Composite#1"/> 
>         <command descriptive="AMF Configuration... Ctrl+Shift+F"  
> type="select" resolverId="org.eclipse.tptp.test.auto.gui.nontrivial"  
> contextId="menus" widgetId="{{Clovis-AMF  
> Configuration...&#x9;Ctrl+Shift+F}}-{{1.0}}"/> 
>         <shell descriptive="TestModel - AMF Configuration"  
> id="com.clovis.cw.editor.ca.dialog.NodeProfileDialog" return-code="0"> 
>             <command descriptive="AMS Configuration" type="item-expand"  
> contextId="shell" widgetId="org.eclipse.swt.widgets.Tree#1" value="true"> 
>                 <item path="{{AMFNode}}-{{1.0}}"  
> resolverId="org.eclipse.tptp.test.auto.gui.adaptive"/> 
>             </command> 
>             <command descriptive="Service Group List" type="item-select"  
> contextId="shell" widgetId="org.eclipse.swt.widgets.Tree#1"> 
>                 <item path="{{Service Group List}}-{{1.0}}"  
> resolverId="org.eclipse.tptp.test.auto.gui.adaptive"/> 
>             </command> 
>             <command descriptive="New" type="select"  
> resolverId="org.eclipse.tptp.test.auto.gui.adaptive"  
> contextId="popup/shell/org.eclipse.swt.widgets.Tree#1"  
> widgetId="{{AMFNew}}-{{1.0}}"/> 
>             <command descriptive="SAFComponent0SG" type="choice-select"  
> contextId="shell" widgetId="org.eclipse.swt.custom.CCombo#1"  
> choiceId="item#0"/> 
>             <command descriptive="OK" type="select"  
> resolverId="org.eclipse.tptp.test.auto.gui.adaptive" contextId="shell"  
> widgetId="{{0}}-{{1.0}}"/> 
>         </shell> 
>     </shell> 
> </macro> 
>  
> Thanks, 
> Pushparaj 
>
 |  
 |  
  |   
Goto Forum:
 
 Current Time: Tue Nov 04 05:17:37 EST 2025 
 Powered by  FUDForum. Page generated in 5.14425 seconds  
 |