Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » SWTBot » MenuItem disposed
MenuItem disposed [message #479388] Mon, 10 August 2009 20:26 Go to next message
Will Horn is currently offline Will HornFriend
Messages: 265
Registered: July 2009
Senior Member
I'm accessing a view context menu item with:

SWTBotMenu deployItem = swtBotTreeItem.contextMenu("Deploy...")

This works when the test is run by itself, but in a suite of other tests, I
consistently get :

org.eclipse.swtbot.swt.finder.exceptions.WidgetNotFoundExcep tion: The
widget {(an instance of org.eclipse.swt.widgets.MenuItem and with mnemonic
'Deploy...')} was disposed.

I've seen similar posts, but have not found any solutions. Is there one?

-Will
Re: MenuItem disposed [message #479424 is a reply to message #479388] Tue, 11 August 2009 00:07 Go to previous messageGo to next message
Kay-Uwe Graw is currently offline Kay-Uwe GrawFriend
Messages: 24
Registered: July 2009
Junior Member
Have a look at bug 279351. The fix I posted there worked for me to solve
this problem.

Kay
Re: MenuItem disposed [message #479902 is a reply to message #479388] Thu, 13 August 2009 00:12 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: jconlon.apache.org

I've really had a problem with this as well.

After much struggle I came across the helper Stefan Seelmann suggested in:
http://dev.eclipse.org/mhonarc/newsLists/news.eclipse.swtbot /msg00712.html

cheers,
John
Re: MenuItem disposed [message #481229 is a reply to message #479388] Thu, 20 August 2009 08:16 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: steve.monnier.obeo.fr

Hello!
I had the same problem using the tree on the outline view (but was working
on navigator view...).
In the contextMenu method in AbstractSWTBot, menuFinder.findMenus(matcher)
is called twice. Once in the waitUntil, and once to return the SWTBotMenu.
I have not found why but for some views the menuItem is disposed at the
second call.

As I wanted to click on a menu, I solved my problem by directly clicking
the menu when it is found. You can try this:

public void clickContextMenu(final SWTBotTreeItem treeItem, final String
text)
{
UIThreadRunnable.asyncExec(new VoidResult()
{
public void run()
{
Control control = treeItem.widget.getParent();
Matcher<MenuItem> withMnemonic = withMnemonic(text);
final Matcher<MenuItem> matcher =
allOf(widgetOfType(MenuItem.class), withMnemonic);
final ContextMenuFinder menuFinder = new
ContextMenuFinder(control);

new SWTBot().waitUntil(new DefaultCondition()
{
public String getFailureMessage()
{
return "Could not find context menu with text: " +
text; //$NON-NLS-1$
}

public boolean test() throws Exception
{
List<MenuItem> findMenus =
menuFinder.findMenus(matcher);
if (findMenus.size() > 0)
{
Iterator<MenuItem> iterator =
findMenus.iterator();
while (iterator.hasNext())
{
MenuItem menuItem = (MenuItem)
iterator.next();

if (!menuItem.isDisposed())
{
new SWTBotMenu(menuItem,
matcher).click();
}
}
}
return !findMenus.isEmpty();
}
});
}
});
}

I hope this can help you,
Steve
Re: MenuItem disposed [message #506570 is a reply to message #481229] Fri, 08 January 2010 03:57 Go to previous messageGo to next message
jetcai  is currently offline jetcai Friend
Messages: 1
Registered: January 2010
Junior Member
Hi,recently I met the kind of problem,but I want to right click a tree and popup a menu,but the menu has many submenu,such as: New-->Java Project. How to do it?
Re: MenuItem disposed [message #517509 is a reply to message #506570] Sun, 28 February 2010 22:46 Go to previous message
Eclipse UserFriend
Originally posted by: peterka.jiri.gmail.com

Hi, you can try #clickContextMenu(final AbstractSWTBot<?> bot,final
String... texts) shown here
http://www.eclipse.org/forums/index.php?t=msg&th=11863&a mp;start=0&

-- Jiri

On 01/08/2010 04:57 AM, jetcai wrote:
> Hi,recently I met the kind of problem,but I want to right click a tree
> and popup a menu,but the menu has many submenu,such as: New-->Java
> Project. How to do it?
Previous Topic:Problem with Testlistener in headless Mode
Next Topic:Cant Access Errormessage
Goto Forum:
  


Current Time: Thu Apr 18 23:11:11 GMT 2024

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

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

Back to the top