Home » Eclipse Projects » SWTBot » swtBotEclipseEditor.typeText issue
| | | |
Re: swtBotEclipseEditor.typeText issue [message #38968 is a reply to message #38946] |
Tue, 16 June 2009 13:30 |
Pascal G Messages: 157 Registered: July 2009 |
Senior Member |
|
|
Thanks, that solved the issue.
I'm still having problem using the keyboard: whenever I do a key
combination with the ALT key, it fails silently without giving errors.
For example, if I want to type @ on my keyboard, the key combination is
ALT + 2. I have the line @ alt + 2 in my keyboard and I try
keyboard.typeText("@"); All it does is, well, nothing. Altough my other
key combination are recognized, those with alt are never typed. I tried
all 3 keyboard strategies and none works. I don't know if its related,
but Hans Schwaebli made a comment in bug # 273624 claiming that ctrl +
alt + q combination was not working.
I also had another problem with another key combination: shift + <. I
have those two lines in my keyboard file:
> shift + <
< <
When I try to type a > with the AWT strategy, I get an invalid key code
error. It works with the SWT strategy though. I don't think anything
could be done to solve the problem with the AWT strategy, because the
stack trace stops in a native method:
> java.lang.IllegalArgumentException: Invalid key code
> at sun.awt.X11.XRobotPeer.keyPressImpl(Native Method)
> at sun.awt.X11.XRobotPeer.keyPress(XRobotPeer.java:61)
> at java.awt.Robot.keyPress(Robot.java:220)
> at org.eclipse.swtbot.swt.finder.keyboard.AWTKeyboardStrategy.p ressKey(AWTKeyboardStrategy.java:44)
> at org.eclipse.swtbot.swt.finder.keyboard.AbstractKeyboardStrat egy.pressKeys(AbstractKeyboardStrategy.java:56)
> at org.eclipse.swtbot.swt.finder.keyboard.Keyboard.pressKeys(Ke yboard.java:157)
> at org.eclipse.swtbot.swt.finder.keyboard.Keyboard.pressShortcu t(Keyboard.java:123)
> at org.eclipse.swtbot.swt.finder.keyboard.Keyboard.typeCharacte r(Keyboard.java:100)
> at org.eclipse.swtbot.swt.finder.keyboard.Keyboard.typeText(Key board.java:89)
> at org.eclipse.swtbot.swt.finder.keyboard.Keyboard.typeText(Key board.java:77)
> at com.nuecho.plugin.robot.test.ScenarioUITest.editStepGroup(Sc enarioUITest.java:324)
> at com.nuecho.plugin.robot.test.ScenarioUITest.createDummyScena rio(ScenarioUITest.java:201)
> at com.nuecho.plugin.robot.test.ScenarioUITest.setUp(ScenarioUI Test.java:63)
> at junit.framework.TestCase.runBare(TestCase.java:132)
> at org.eclipse.swtbot.swt.finder.SWTBotTestCase.runBare(SWTBotT estCase.java:228)
> at junit.framework.TestResult$1.protect(TestResult.java:110)
> at junit.framework.TestResult.runProtected(TestResult.java:128)
> at junit.framework.TestResult.run(TestResult.java:113)
> at junit.framework.TestCase.run(TestCase.java:124)
> at com.nuecho.plugin.framework.swtbot.AbstractUITest.run(Abstra ctUITest.java:369)
> at junit.framework.TestSuite.runTest(TestSuite.java:232)
> at junit.framework.TestSuite.run(TestSuite.java:227)
> at org.junit.internal.runners.OldTestClassRunner.run(OldTestCla ssRunner.java:76)
> at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.r un(JUnit4TestReference.java:45)
> at org.eclipse.jdt.internal.junit.runner.TestExecution.run(Test Execution.java:38)
> at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTe sts(RemoteTestRunner.java:460)
> at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTe sts(RemoteTestRunner.java:673)
> at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(R emoteTestRunner.java:386)
> at org.eclipse.swtbot.eclipse.core.RemotePluginTestRunner.main( RemotePluginTestRunner.java:64)
> at org.eclipse.swtbot.eclipse.core.UITestApplication.runTests(U ITestApplication.java:123)
> at org.eclipse.ui.internal.testing.WorkbenchTestable$1.run(Work benchTestable.java:68)
> at java.lang.Thread.run(Thread.java:595)
>
here is the full keyboard file:
! shift + 1
" shift + 2
/ shift + 3
$ shift + 4
% shift + 5
? shift + 6
& shift + 7
* shift + 8
( shift + 9
) shift + 0
_ shift + -
+ shift + =
: shift + ;
' shift + ,
| shift + #
> shift + <
[ alt + ^
] alt + ¸
{ alt + `
} alt + <
@ alt + 2
\ alt + #
` `
- -
= =
; ;
, ,
.. .
# #
< <
^ ^
¸ ¸
|
|
|
Re: swtBotEclipseEditor.typeText issue [message #38984 is a reply to message #38968] |
Tue, 16 June 2009 15:28 |
Ketan Padegaonkar Messages: 873 Registered: July 2009 |
Senior Member |
|
|
This happens because the strategy may not understand a particular
keycode. All keys need to be translated to keycodes that the OS can
understand.
Certain characters's ascii code directly map to the keycode, alphabets
and numbers on the US keyboard *generally* fall in this category.
There are obviously exceptions to this, the only one I am aware of at
the moment is the backtick(`) which maps to KeyEvent.VK_BACK_QUOTE and
not its own ascii code.
Out of curiosity are you on a canadian french keyboard layout[1] ? And
by Alt key do you mean AltGr -- from wikipedia, this maps to CTRL+ALT[2]?
I'm unfortunately not using that keyboard and may not be able to provide
much useful information, but my feeling is that the keycode being sent
via AWTKeyboardStrategy#pressKey() is something that is incorrect.
Could you also try the following snippet to provide more info:
myTextBox.setFocus();
k = KeyboardFactory.getAWTKeyboard(); // or the other keyboard strategies
k.pressShortcut(SWT.ALT|SWT.CTRL, '2'); // alt gr = CTRL+ALT
[1] - http://en.wikipedia.org/wiki/Keyboard_layout#Canadian_French
[2] - http://en.wikipedia.org/wiki/AltGr_key#History
--
Ketan
http://studios.thoughtworks.com/twist | http://twitter.com/ketanpkr
On 16/6/09 19:00, Pascal Gelinas wrote:
> Thanks, that solved the issue.
>
> I'm still having problem using the keyboard: whenever I do a key
> combination with the ALT key, it fails silently without giving errors.
> For example, if I want to type @ on my keyboard, the key combination is
> ALT + 2. I have the line @ alt + 2 in my keyboard and I try
> keyboard.typeText("@"); All it does is, well, nothing. Altough my other
> key combination are recognized, those with alt are never typed. I tried
> all 3 keyboard strategies and none works. I don't know if its related,
> but Hans Schwaebli made a comment in bug # 273624 claiming that ctrl +
> alt + q combination was not working.
>
> I also had another problem with another key combination: shift + <. I
> have those two lines in my keyboard file:
> > shift + <
> < <
> When I try to type a > with the AWT strategy, I get an invalid key code
> error. It works with the SWT strategy though. I don't think anything
> could be done to solve the problem with the AWT strategy, because the
> stack trace stops in a native method:
>> java.lang.IllegalArgumentException: Invalid key code
>> at sun.awt.X11.XRobotPeer.keyPressImpl(Native Method)
>> at sun.awt.X11.XRobotPeer.keyPress(XRobotPeer.java:61)
>> at java.awt.Robot.keyPress(Robot.java:220)
>> at
>> org.eclipse.swtbot.swt.finder.keyboard.AWTKeyboardStrategy.p ressKey(AWTKeyboardStrategy.java:44)
>>
>> at
>> org.eclipse.swtbot.swt.finder.keyboard.AbstractKeyboardStrat egy.pressKeys(AbstractKeyboardStrategy.java:56)
>>
>> at
>> org.eclipse.swtbot.swt.finder.keyboard.Keyboard.pressKeys(Ke yboard.java:157)
>>
>> at
>> org.eclipse.swtbot.swt.finder.keyboard.Keyboard.pressShortcu t(Keyboard.java:123)
>>
>> at
>> org.eclipse.swtbot.swt.finder.keyboard.Keyboard.typeCharacte r(Keyboard.java:100)
>>
>> at
>> org.eclipse.swtbot.swt.finder.keyboard.Keyboard.typeText(Key board.java:89)
>>
>> at
>> org.eclipse.swtbot.swt.finder.keyboard.Keyboard.typeText(Key board.java:77)
>>
>> at
>> com.nuecho.plugin.robot.test.ScenarioUITest.editStepGroup(Sc enarioUITest.java:324)
>>
>> at
>> com.nuecho.plugin.robot.test.ScenarioUITest.createDummyScena rio(ScenarioUITest.java:201)
>>
>> at
>> com.nuecho.plugin.robot.test.ScenarioUITest.setUp(ScenarioUI Test.java:63)
>> at junit.framework.TestCase.runBare(TestCase.java:132)
>> at
>> org.eclipse.swtbot.swt.finder.SWTBotTestCase.runBare(SWTBotT estCase.java:228)
>>
>> at junit.framework.TestResult$1.protect(TestResult.java:110)
>> at junit.framework.TestResult.runProtected(TestResult.java:128)
>> at junit.framework.TestResult.run(TestResult.java:113)
>> at junit.framework.TestCase.run(TestCase.java:124)
>> at
>> com.nuecho.plugin.framework.swtbot.AbstractUITest.run(Abstra ctUITest.java:369)
>>
>> at junit.framework.TestSuite.runTest(TestSuite.java:232)
>> at junit.framework.TestSuite.run(TestSuite.java:227)
>> at
>> org.junit.internal.runners.OldTestClassRunner.run(OldTestCla ssRunner.java:76)
>>
>> at
>> org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.r un(JUnit4TestReference.java:45)
>>
>> at
>> org.eclipse.jdt.internal.junit.runner.TestExecution.run(Test Execution.java:38)
>>
>> at
>> org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTe sts(RemoteTestRunner.java:460)
>>
>> at
>> org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTe sts(RemoteTestRunner.java:673)
>>
>> at
>> org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(R emoteTestRunner.java:386)
>>
>> at
>> org.eclipse.swtbot.eclipse.core.RemotePluginTestRunner.main( RemotePluginTestRunner.java:64)
>>
>> at
>> org.eclipse.swtbot.eclipse.core.UITestApplication.runTests(U ITestApplication.java:123)
>>
>> at
>> org.eclipse.ui.internal.testing.WorkbenchTestable$1.run(Work benchTestable.java:68)
>>
>> at java.lang.Thread.run(Thread.java:595)
>>
>
>
> here is the full keyboard file:
> ! shift + 1
> " shift + 2
> / shift + 3
> $ shift + 4
> % shift + 5
> ? shift + 6
> & shift + 7
> * shift + 8
> ( shift + 9
> ) shift + 0
> _ shift + -
> + shift + =
> : shift + ;
> ' shift + ,
> | shift + #
> > shift + <
> [ alt + ^
> ] alt + ¸
> { alt + `
> } alt + <
> @ alt + 2
> \ alt + #
> ` `
> - -
> = =
> ; ;
> , ,
> .. .
> # #
> < <
> ^ ^
> ¸ ¸
|
|
| |
Re: swtBotEclipseEditor.typeText issue [message #39207 is a reply to message #38984] |
Tue, 16 June 2009 20:32 |
Pascal G Messages: 157 Registered: July 2009 |
Senior Member |
|
|
Ketan Padegaonkar wrote:
> There are obviously exceptions to this, the only one I am aware of at
> the moment is the backtick(`) which maps to KeyEvent.VK_BACK_QUOTE and
> not its own ascii code.
It seems like most of the special characters don't map their ascii code
to their AWT keycode. For example, # maps to KeyEvent.VK_NUMBER_SIGN (0x208)
> Out of curiosity are you on a canadian french keyboard layout[1] ? And
> by Alt key do you mean AltGr -- from wikipedia, this maps to CTRL+ALT[2]?
I have a standard US layout keyboard but I change the native support to
make the keys map to a canadian french keyboard. And I meant the ALT, I
had no idea about the AltGr. I've changed alt for ctrl + alt in my
keyboard file.
> I'm unfortunately not using that keyboard and may not be able to provide
> much useful information, but my feeling is that the keycode being sent
> via AWTKeyboardStrategy#pressKey() is something that is incorrect.
I took a look in AWTKeyboardStrategy and I think this line is missing in
the static block (in 2.0.0.329-dev):
addModifierKeyMapping(SWT.CTRL | SWT.ALT, KeyEvent.VK_ALT_GRAPH);
without that line, I get an IllegalArgumentException: Could not
understand keystroke CTRL+ALT+
I've taken the liberty to make a local copy of the class on which I
could make some tests. I've added the key mapping (and some more for the
special characters as mentioned above) and it types 2 instead of @. Same
thing happens with the SWT strategy and the Mock fail silently.
> Could you also try the following snippet to provide more info:
>
> myTextBox.setFocus();
> k = KeyboardFactory.getAWTKeyboard(); // or the other keyboard strategies
> k.pressShortcut(SWT.ALT|SWT.CTRL, '2'); // alt gr = CTRL+ALT
All 4 strategies (Mock, SWT, AWT and mine) fail silently, without typing
anything. I'm beginning to suspect a platform specific issue: even when
I use ctrl+alt+2 on my keyboard it doesn't do anything (and AltGr+2
works), and I've asked a colleague that works under windows and the
ctrl+alt works for him. I'm going to do some tests on Windows and see
what happens.
P
|
|
|
Re: swtBotEclipseEditor.typeText issue [message #39238 is a reply to message #39207] |
Wed, 17 June 2009 05:33 |
Ketan Padegaonkar Messages: 873 Registered: July 2009 |
Senior Member |
|
|
I tried typing a '#' using on my standard US mac keyboard, and it seems
to work fine with the defaults.
I've created a high priority bug for this:
https://bugs.eclipse.org/bugs/show_bug.cgi?id=280562
Please add yourself to cc on that bug so I can track this better. The
following information will help:
- swtbot version
- eclipse version
- platform OS/WS/arch
- jdk version
Cheers!
--
Ketan
http://studios.thoughtworks.com/twist | http://twitter.com/ketanpkr
On 17/6/09 02:02, Pascal Gelinas wrote:
> Ketan Padegaonkar wrote:
>
>> There are obviously exceptions to this, the only one I am aware of at
>> the moment is the backtick(`) which maps to KeyEvent.VK_BACK_QUOTE and
>> not its own ascii code.
>
> It seems like most of the special characters don't map their ascii code
> to their AWT keycode. For example, # maps to KeyEvent.VK_NUMBER_SIGN
> (0x208)
>
>> Out of curiosity are you on a canadian french keyboard layout[1] ? And
>> by Alt key do you mean AltGr -- from wikipedia, this maps to CTRL+ALT[2]?
>
> I have a standard US layout keyboard but I change the native support to
> make the keys map to a canadian french keyboard. And I meant the ALT, I
> had no idea about the AltGr. I've changed alt for ctrl + alt in my
> keyboard file.
>
>> I'm unfortunately not using that keyboard and may not be able to
>> provide much useful information, but my feeling is that the keycode
>> being sent via AWTKeyboardStrategy#pressKey() is something that is
>> incorrect.
>
> I took a look in AWTKeyboardStrategy and I think this line is missing in
> the static block (in 2.0.0.329-dev):
> addModifierKeyMapping(SWT.CTRL | SWT.ALT, KeyEvent.VK_ALT_GRAPH);
>
> without that line, I get an IllegalArgumentException: Could not
> understand keystroke CTRL+ALT+
>
> I've taken the liberty to make a local copy of the class on which I
> could make some tests. I've added the key mapping (and some more for the
> special characters as mentioned above) and it types 2 instead of @. Same
> thing happens with the SWT strategy and the Mock fail silently.
>
>> Could you also try the following snippet to provide more info:
>>
>> myTextBox.setFocus();
>> k = KeyboardFactory.getAWTKeyboard(); // or the other keyboard strategies
>> k.pressShortcut(SWT.ALT|SWT.CTRL, '2'); // alt gr = CTRL+ALT
>
> All 4 strategies (Mock, SWT, AWT and mine) fail silently, without typing
> anything. I'm beginning to suspect a platform specific issue: even when
> I use ctrl+alt+2 on my keyboard it doesn't do anything (and AltGr+2
> works), and I've asked a colleague that works under windows and the
> ctrl+alt works for him. I'm going to do some tests on Windows and see
> what happens.
>
> P
|
|
| |
Re: swtBotEclipseEditor.typeText issue [message #42784 is a reply to message #42722] |
Fri, 10 July 2009 12:27 |
Pascal G Messages: 157 Registered: July 2009 |
Senior Member |
|
|
Benjamin Glaser wrote:
> First I wondered why textbox.typeText("Text") don't works for me.
> Now I found this discussion, and I think my problem is the missing
> KeyboardLayout DE_DE.
>
> Unfortunately I have no idea how to get or create a matching
> KeyboardLayout.
>
> Would be great if somebody helps me out.
>
> Thanks Benjamin
>
Take the EN_US keyboard bundled with SWTBot as an example to start out.
The keyboard file contains the key sequence you have to type for a
specific character. For example, I think the '@' character is typed with
AltGr + q on a DE keyboard. Another example would be the '"' character
on a FR_CA, which is typed using shift + 2.
However, I would rather suggest you use a standard US keyboard instead
because both SWT and AWT can't reproduce the AltGr key. There is an open
bug in SWT and SWTBot to make this work. See
https://bugs.eclipse.org/bugs/show_bug.cgi?id=280824 and
https://bugs.eclipse.org/bugs/show_bug.cgi?id=280562.
To make use of a standard US keyboard, you need to do two things:
1- Change the native layout of your keyboard. Doing so depends on your
OS: on linux, type in a shell: setxkbmap us. On windows, the language
bar can do this. On a Mac, you'd better ask Ketan :P
2- Change the default keyboard layout in SWTBot. SWTBot tries to guess
the native keyboard layout based on the locale you are on, but it rarely
does a good guess when you change your native support (due to lack of
functionality in SWT). Change the SWTBotPreference#KEYBOARD_LAYOUT to
"EN_US".
You should be set on using the typeText method.
Hope this help.
--
Pascal Gélinas | Software Developer
*Nu Echo Inc.*
http://www.nuecho.com/ | http://blog.nuecho.com/
*Because performance matters.*
|
|
| | |
Goto Forum:
Current Time: Thu Nov 14 09:02:11 GMT 2024
Powered by FUDForum. Page generated in 0.03808 seconds
|