Key Press: Enter [message #45050] |
Wed, 22 July 2009 19:59  |
Eclipse User |
|
|
|
Ketan,
I have been writing a test case with SWTBot and one of the requirements is
to type a keyboard shortcut CTRL + SHFT + Enter. I can successfully press
the first two keys, but am unable to press the Enter key because in the
SWT class there is not equivalent for SWT.ENTER. Below are a few lines of
code I have written. Any Suggestions on how I can test the pressing of the
Enter key?
KeyStroke ctrl = KeyStroke.getInstance(SWT.CTRL, 0);
KeyStroke shift = KeyStroke.getInstance(SWT.SHIFT, 0);
//KeyStroke ret = KeyStroke.getInstance(0, SWT.???);
bot.sleep(2000);
//k.pressShortcut(ctrl, shift, ret);
Thanks,
Mike
|
|
|
Re: Key Press: Enter [message #45062 is a reply to message #45050] |
Thu, 23 July 2009 00:18   |
Eclipse User |
|
|
|
Keystrokes.CR and Keystrokes.LF is what you're looking for.
Some more keystrokes here:
http://github.com/ketan/swtbot/blob/9f2a3beb6dc00e8827fe127e ec589a80bcdfe6b6/org.eclipse.swtbot.swt.finder/src/org/eclip se/swtbot/swt/finder/keyboard/Keystrokes.java
--
Ketan
http://studios.thoughtworks.com/twist | http://twitter.com/ketanpkr
On 23/7/09 05:29, Michael Wiederhold wrote:
> Ketan,
>
> I have been writing a test case with SWTBot and one of the requirements
> is to type a keyboard shortcut CTRL + SHFT + Enter. I can successfully
> press the first two keys, but am unable to press the Enter key because
> in the SWT class there is not equivalent for SWT.ENTER. Below are a few
> lines of code I have written. Any Suggestions on how I can test the
> pressing of the Enter key?
> KeyStroke ctrl = KeyStroke.getInstance(SWT.CTRL, 0);
> KeyStroke shift = KeyStroke.getInstance(SWT.SHIFT, 0);
> //KeyStroke ret = KeyStroke.getInstance(0, SWT.???);
> bot.sleep(2000);
> //k.pressShortcut(ctrl, shift, ret);
>
> Thanks,
> Mike
>
|
|
|
|
|
Re: Key Press: Enter [message #485920 is a reply to message #485787] |
Tue, 15 September 2009 10:38  |
Eclipse User |
|
|
|
Thanks again for your quick response, Ketan. After I had posted my question I kept trying to get this to work. I found this code was also successful without using the KeyStroke specification:
textEditor.typeText("test line " + l);
textEditor.pressShortcut(SWT.CR, SWT.LF);
Michelle
|
|
|
Powered by
FUDForum. Page generated in 0.57366 seconds