Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » SWTBot » SWTBotTreeItem's context menu click gives TimeoutException(SWTBotTreeItem's context menu click gives TimeoutException)
SWTBotTreeItem's context menu click gives TimeoutException [message #1416063] Thu, 04 September 2014 08:50 Go to next message
Aparna Argade is currently offline Aparna ArgadeFriend
Messages: 60
Registered: October 2010
Member
I was using swtbot 2.0.5. Recently I've started using swtbot 2.2.2 on eclipse 4.4.
I observed that SWTBotTreeItem's contextmenu click is giving TimeoutException.
My test-snippet is very simple-
SWTBotTreeItem ti = bot().tree().getTreeItem("i");
ti.contextMenu("Disable").click();

Here I'm getting 'SWTBotTreeItem ti' correctly. It's context menu 'Disable' is enabled in UI.

org.eclipse.swtbot.swt.finder.widgets.TimeoutException: Timeout after: 5000 ms.: Could not find context menu with text 'Disable'
Caused by: org.eclipse.core.runtime.AssertionFailedException: null argument:Action must not be null
at org.eclipse.core.runtime.Assert.isNotNull(Assert.java:85)
at org.eclipse.jface.action.ContributionManager.add(ContributionManager.java:76)
at org.eclipse.debug.internal.ui.views.expression.ExpressionView.fillContextMenu(ExpressionView.java:89)

Has anyone faced such problem?
Re: SWTBotTreeItem's context menu click gives TimeoutException [message #1416222 is a reply to message #1416063] Thu, 04 September 2014 15:47 Go to previous messageGo to next message
Mickael Istria is currently offline Mickael IstriaFriend
Messages: 865
Registered: July 2009
Location: Grenoble, France
Senior Member

> org.eclipse.swtbot.swt.finder.widgets.TimeoutException: Timeout after:
> 5000 ms.: Could not find context menu with text 'Disable'
> Caused by: org.eclipse.core.runtime.AssertionFailedException: null
> argument:Action must not be null
> at org.eclipse.core.runtime.Assert.isNotNull(Assert.java:85)
> at
> org.eclipse.jface.action.ContributionManager.add(ContributionManager.java:76)
>
> at
> org.eclipse.debug.internal.ui.views.expression.ExpressionView.fillContextMenu(ExpressionView.java:89)

This stack doesn't seem related to SWTBot. You should check what can be
a cause of this error.
But it might also be in bug in SWTBot not sending the right menu event...
--
Mickael Istria
My job: http://www.jboss.org/tools
My blog: http://mickaelistria.wordpress.com
My Tweets: http://twitter.com/mickaelistria
Re: SWTBotTreeItem's context menu click gives TimeoutException [message #1417555 is a reply to message #1416222] Fri, 05 September 2014 17:39 Go to previous messageGo to next message
Aparna Argade is currently offline Aparna ArgadeFriend
Messages: 60
Registered: October 2010
Member
This happens with swtbot 2.2.1 (or 2.2.2) + eclipse 4.4 combination.
Context menu click happens for swtbot 2.2.1 (or 2.2.2) + eclipse 3.7.2 combination.


Re: SWTBotTreeItem's context menu click gives TimeoutException [message #1422088 is a reply to message #1417555] Fri, 12 September 2014 09:58 Go to previous messageGo to next message
Aparna Argade is currently offline Aparna ArgadeFriend
Messages: 60
Registered: October 2010
Member
After debugging, I observed following things-
1. After launcing swtbot test, the debug views (e.g. Expressions) in Debug Perspective doesn't show any data, it comes only as white space with just 'Expressions' Tab. If I close the Expressions view and open it again (manually or through test) then it shows the data.

2. After stepping into the code for 'contextMenu', I observed that:
ExpressionView class in eclipse has a method 'fillContextMenu'. There it gets 'find' actionitem as null.
After exploring little more, I found that 'AbstractDebugView' class gets called for putting actionID for 'find' action for FoucusGained event. Again it gets called for FocusLost event and the 'find' actionID is removed from ExpressionView's fActionMap. After this sequence, 'fillContextMenu' is called where it doesn't get 'find' actionID because it's just has been removed..

Has anybody tried e4+swtbot 2.2.2 (or swtbot 2.2.1) combination?

The complete stack trace (with swtbot plugins) is as follows:
Caused by: org.eclipse.core.runtime.AssertionFailedException: null argument:Action must not be null
at org.eclipse.core.runtime.Assert.isNotNull(Assert.java:85)
at org.eclipse.jface.action.ContributionManager.add(ContributionManager.java:76)
at org.eclipse.debug.internal.ui.views.expression.ExpressionView.fillContextMenu(ExpressionView.java:89)
at org.eclipse.debug.ui.AbstractDebugView$2.menuAboutToShow(AbstractDebugView.java:556)
at org.eclipse.jface.action.MenuManager.fireAboutToShow(MenuManager.java:352)
at org.eclipse.jface.action.MenuManager.handleAboutToShow(MenuManager.java:492)
at org.eclipse.jface.action.MenuManager.access$1(MenuManager.java:487)
at org.eclipse.jface.action.MenuManager$2.menuShown(MenuManager.java:519)
at org.eclipse.swt.widgets.TypedListener.handleEvent(TypedListener.java:255)
at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:84)
at org.eclipse.swt.widgets.Display.sendEvent(Display.java:4353)
at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1061)
at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1085)
at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1070)
at org.eclipse.swt.widgets.Widget.notifyListeners(Widget.java:782)
at org.eclipse.swtbot.swt.finder.finders.MenuFinder.findMenusInternal(MenuFinder.java:152)
at org.eclipse.swtbot.swt.finder.finders.MenuFinder.access$0(MenuFinder.java:149)
at org.eclipse.swtbot.swt.finder.finders.MenuFinder$2.run(MenuFinder.java:124)
at org.eclipse.swtbot.swt.finder.finders.MenuFinder$2.run(MenuFinder.java:1)
at org.eclipse.swtbot.swt.finder.finders.UIThreadRunnable$2.doRun(UIThreadRunnable.java:140)
at org.eclipse.swtbot.swt.finder.finders.UIThreadRunnable$1.run(UIThreadRunnable.java:89)
at org.eclipse.swt.widgets.RunnableLock.run(RunnableLock.java:35)
at org.eclipse.swt.widgets.Synchronizer.runAsyncMessages(Synchronizer.java:136)
... 25 more

JUnit fails with :
org.eclipse.swtbot.swt.finder.widgets.TimeoutException: Timeout after: 5000 ms.: Could not find context menu with text: Disable
at org.eclipse.swtbot.swt.finder.SWTBotFactory.waitUntil(SWTBotFactory.java:412)
at org.eclipse.swtbot.swt.finder.SWTBotFactory.waitUntil(SWTBotFactory.java:386)
at org.eclipse.swtbot.swt.finder.SWTBotFactory.waitUntil(SWTBotFactory.java:374)
at org.eclipse.swtbot.swt.finder.widgets.AbstractSWTBot.contextMenu(AbstractSWTBot.java:444)
at org.eclipse.swtbot.swt.finder.widgets.SWTBotTreeItem.contextMenu(SWTBotTreeItem.java:559)
Re: SWTBotTreeItem's context menu click gives TimeoutException [message #1422112 is a reply to message #1422088] Fri, 12 September 2014 10:40 Go to previous messageGo to next message
Mickael Istria is currently offline Mickael IstriaFriend
Messages: 865
Registered: July 2009
Location: Grenoble, France
Senior Member

On 09/12/2014 11:58 AM, Aparna Argade wrote:
> 2. After stepping into the code for 'contextMenu', I observed that:
> ExpressionView class in eclipse has a method 'fillContextMenu'. There it
> gets 'find' actionitem as null. After exploring little more, I found
> that 'AbstractDebugView' class gets called for putting actionID for
> 'find' action for FoucusGained event. Again it gets called for FocusLost
> event and the 'find' actionID is removed from ExpressionView's
> fActionMap. After this sequence, 'fillContextMenu' is called where it
> doesn't get 'find' actionID because it's just has been removed..
> Has anybody tried e4+swtbot 2.2.2 (or swtbot 2.2.1) combination?

This is pretty interesting. I believe it's related to some of those
known bugs:
* https://bugs.eclipse.org/bugs/show_bug.cgi?id=388306
* https://bugs.eclipse.org/bugs/show_bug.cgi?id=363916
* https://bugs.eclipse.org/bugs/show_bug.cgi?id=437915

Please add your analysis and suggestions to the bug that seems the most
related. I believe your experiments here can drive to a good fix.

--
Mickael Istria
My job: http://www.jboss.org/tools
My blog: http://mickaelistria.wordpress.com
My Tweets: http://twitter.com/mickaelistria
Re: SWTBotTreeItem's context menu click gives TimeoutException [message #1425293 is a reply to message #1422112] Wed, 17 September 2014 05:11 Go to previous messageGo to next message
Aparna Argade is currently offline Aparna ArgadeFriend
Messages: 60
Registered: October 2010
Member
I've put my comments in bug 363916. I'm eagerly waiting for these bug fixes.
Re: SWTBotTreeItem's context menu click gives TimeoutException [message #1425613 is a reply to message #1425293] Wed, 17 September 2014 15:00 Go to previous messageGo to next message
Mickael Istria is currently offline Mickael IstriaFriend
Messages: 865
Registered: July 2009
Location: Grenoble, France
Senior Member

On 09/17/2014 07:11 AM, Aparna Argade wrote:
> I've put my comments in bug 363916. I'm eagerly waiting for these bug
> fixes.

The best way to get a bug fixed is not to wait, but to provide a patch ;)
http://wiki.eclipse.org/SWTBot/Contributing

--
Mickael Istria
My job: http://www.jboss.org/tools
My blog: http://mickaelistria.wordpress.com
My Tweets: http://twitter.com/mickaelistria
Re: SWTBotTreeItem's context menu click gives TimeoutException [message #1429440 is a reply to message #1425613] Tue, 23 September 2014 08:28 Go to previous messageGo to next message
Aparna Argade is currently offline Aparna ArgadeFriend
Messages: 60
Registered: October 2010
Member
Please tell me if somebody knows about this-
In eclipse 3.7.2, it is seen that there were 2 actions-
1. find
2. find.Variables (declared in org.eclipse.debug.internal.ui.views.variables.VariablesView)

'find' action gets called on FocusGained or FocusLost events.

But 'ExpressionView.fillContextMenu' function looks for find.Variables event with the statement-

menu.add(getAction(VARIABLES_FIND_ELEMENT_ACTION));

It gets this action & the context menu click occurs even though 'find' action had been removed by FocusLost event.

In e4, fillContextMenu has the line- menu.add(getAction(FIND_ACTION));
e4 uses only one 'find' action which is also added/removed on FocusGained/FocusLost events and also looked for in fillContextMenu function.
Is this cause of the problem? Why is find.Variables action is removed in e4? Then how to deal with only one 'find' action?
Re: SWTBotTreeItem's context menu click gives TimeoutException [message #1471762 is a reply to message #1429440] Thu, 13 November 2014 10:06 Go to previous message
Aparna Argade is currently offline Aparna ArgadeFriend
Messages: 60
Registered: October 2010
Member
It seems I found how to make it work!
Actually the problem was caused due to not finding entry in fActionMap upon FocusLost event, which gets called as a result of SWTBotTreeItem.notifySelect().

If I comment out the line which sends SWT.FocusOut event in SWTBotTreeItem.notifySelect() method, then context menu click happens without any problem. UI also gets updated, as expected.
After commenting out this line, FocusLost routine of VariablesView in eclipse is not called and hence the globalActions (e.g. 'find' action) is not removed. Therefore, fActionMap gets entry for 'find' action in fillContextMenu() method of VariablesView and the further code also executes well.
Is this solution okay? Will it have any side-effects?
Please share your thoughts.

I've one more question--
If I compare implementation of notifySelect() method of SWTBotTableItem and SWTBotTreeItem, I see that-
SWTBotTableItem sends only SWT.Selection and SWTBotTreeItem sends a series of SWT events like MouseEnter, MouseMove, Activate, FocusIn and so on.
Are all these events required?
If I comment-out all events and keep only SWT.Selection in SWTBotTreeItem.notifySelect(), then also context menu click happens okay.
Is SWT.Selection alone not sufficient?

I'm not able to figure out the need for each event here. It would be very helpful if somebody explains it.
Thanks..
Aparna
Previous Topic:Anyone knows a way to click on submenus of a view menu?
Next Topic:@RunWith(SWTBotJunit4ClassRunner.class) won't catch screenshots on failure
Goto Forum:
  


Current Time: Tue Mar 19 10:10:43 GMT 2024

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

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

Back to the top