Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

using keyboard with swtbot test

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

like image 928
Ziv Salzman Avatar asked Jan 23 '26 16:01

Ziv Salzman


2 Answers

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"));
like image 77
aphex Avatar answered Jan 25 '26 06:01

aphex


For multiple modifiers keys you can use

item.select().pressShortcut(SWT.CTRL | SWT.ALT, 'F');
like image 30
coder11 Avatar answered Jan 25 '26 05:01

coder11



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!