How to access Sirius edition table's cell editor from SWTBot? [message #1836885] |
Sun, 17 January 2021 11:44  |
Eclipse User |
|
|
|
Hi,
I am trying to use SWTBot to test my sirius rcp application. There are some edition tables in my app, and I want to automatically test the cell editors in those edition tables. However, I've met a problem. The cells in the edition table can be double clicked and then user can edit directly in it. My problem is that I cannot find a way to trigger the double click action for a selected cell using SWTBot.
I've tried SWTBotTreeItem.dobleClick, but that method cannot locate to a specified cell(column). I then tried the AbstractSWTBotTreeItem.doubleClickXY method, but the method seems doesn't work at all.
Is there any way to trigger the double click action in the specified edition table cell using SWTBot? Any advice helps.
Thanks.
Yufei Zhou
|
|
|
|
Re: How to access Sirius edition table's cell editor from SWTBot? [message #1836902 is a reply to message #1836896] |
Mon, 18 January 2021 05:56   |
Eclipse User |
|
|
|
Hello,
Indeed, you can look at the method org.eclipse.sirius.tests.swtbot.ManualAirdModificationTest.directEditLabel(SWTBotEditor, String, char) or org.eclipse.sirius.tests.swtbot.table.CellEditionTest.testEditBooleanCellWithOtherColumnOnSameFeatureName() for examples on how we proceed to edit a table cell.
For SWTBot, a table is handled as a tree where a treeItem is a line of cells. Therefore, if you want to modify a cell, you will first navigate to its line. You can access it by its index or by the current value of one of its cell.
By index:
SWTBotTreeItem[] items = table.getTable().getAllItems();
items[1].select();
By value:
SWTBotTreeItem tableItem = editor.bot().tree().getTreeItem(oldValue);
tableItem.select();
Now that you have the line, you can click on the cell you want to edit by its index, for instance: tableItem.click(2);
This will set focus on the cell you want to edit. After that, as a user you would only need to "press the keyboard keys", that's why we added this helper: SWTBotUtils.directEditWithKeyboard(tableTree.widget, newValue);
Best regards,
Steve
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.10557 seconds