Question

I'm trying to run SWTbot test case that uses keyboard short-cuts. I could not find any reference for how to do it.

I'm pretty sure that should not be that difficult. I'll appreciate it if someone can write a small snippet.

Thanks,

Ziv

Was it helpful?

Solution

What about using the pressShortcut() methood?

For TreeItem:

final SWTBotTreeItem item = ...
item.select().pressShortcut(SWT.CTRL, 'F');

For TableItem:

final SWTBotTableItem item = ...
item.select().pressShortcut(SWT.CTRL, 'F');

For EclipseEditor

((SWTBotEclipseEditor)bot.activeEditor()).pressShortcut(SWT.CTRL, '1')

From Active Shell:

 bot.activeShell().pressShortcut(
        Keystrokes.CTRL, KeyStroke.getInstance("1"));

OTHER TIPS

For multiple modifiers keys you can use

item.select().pressShortcut(SWT.CTRL | SWT.ALT, 'F');
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top