Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Standard Widget Toolkit (SWT) » Programatically open a menu from menubar(Simulate the menu click programmatically for UI automation test)
Programatically open a menu from menubar [message #938884] Wed, 10 October 2012 08:37
Somesh Rathi is currently offline Somesh RathiFriend
Messages: 7
Registered: August 2012
Junior Member
Hello,

MenuManager and Menu Contribution items has been already created.

For the input Menu Item id/label , i need to problematically drop-down/open/display a menu item from menubar in eclipse.I think i may need to fire some event.

This is requirement for UI Automation that Menu should be drop down automatically.

Can you please help at the earliest. I'm trying following , but here not sure how to set the X & y co-ordinates where mouse click event should be fired.

		String toCompare = "File";
		Menu menu = window.getShell().getMenuBar();
		if(menu!=null && !menu.isDisposed()){
			MenuItem[] items = menu.getItems();
			for(int i=0;i<items.length;i++){
				String menuText = LegacyActionTools.removeMnemonics(items[i].getText());
				if(toCompare.equalsIgnoreCase(menuText)){
					Event event = new Event();
					event.doit = true;
					
					event.widget = items[i];
					event.type = SWT.MouseDown;
					event.button = 1;
					
					boolean success = items[i].getDisplay().post(event);
					System.out.println("Could we generate the event ? "+success);
				}						
			}
Previous Topic:Odd solution to a hang, now thoroughly confused
Next Topic:Show values into TableEditor
Goto Forum:
  


Current Time: Tue Dec 23 00:54:29 GMT 2014

Powered by FUDForum. Page generated in 0.01576 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software