popup menu in NatTable could'nt be found [message #1817372] |
Thu, 21 November 2019 10:09 |
Ralf Heydenreich Messages: 235 Registered: July 2009 |
Senior Member |
|
|
Hi all,
I'm testing a NatTable widget and tried to execute a command from a popup menu. So, I used the following code:
botNatTable.clickColumnHeader(4, true);
UIThreadRunnable.syncExec(() -> botNatTable.contextMenu("Delete Column").click());
Firstly, I omitted the UI thread wrapping which leads to a "Wrong Thread" error message. Now, if I use the UI thread, the popup menu isn't found (timeout while searching for it).
The implementation of botNatTable.contextMenu is
ContextMenuHelper.notifyMenuDetect(control, widget);
WaitForObjectCondition<Menu> waitForMenu = Conditions.waitForPopupMenu(control);
new SWTBot().waitUntilWidgetAppears(waitForMenu);
return new SWTBotRootMenu(waitForMenu.get(0));
What is the correct way to implement such a test?
TIA,
Ralf.
[Updated on: Thu, 21 November 2019 10:30] Report message to a moderator
|
|
|
Re: popup menu in NatTable could'nt be found [message #1817395 is a reply to message #1817372] |
Thu, 21 November 2019 15:34 |
Patrick Tasse Messages: 85 Registered: July 2009 |
Member |
|
|
Hi Ralf,
It isn't normal that you need to wrap SWTBot code in a UIThreadRunnable. All SWTBot API are expected to be called from a test thread, not the UI thread. Could you share the stack trace?
For context menu, normally you only need to call contextMenu() on a SWTBot widget that represents what you are clicking on. I see you are trying to invoke context menu on a column header.
For a normal Table widget, we have SWTBotTable.header() that returns a SWTBotTableColumn, on which you can invoke contextMenu().
For NatTable, I see that there is SWTBotNatTable.contextMenu(row, column) that can be used to invoke the context menu on a cell.
I guess there is no capability in SWTBotNatTable to invoke the context menu on a column or row header.
If you would like to contribute that capability, we will be happy to review it. Otherwise you can write a bug enhancement request and will have to wait for someone to have time to do it.
Looking at your code snippet, I was wondering what is the class of botNatTable? I do not see any method called clickColumnHeader() in SWTBotNatTable?
Hope this helps,
Patrick
|
|
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.05629 seconds