Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » SWTBot » Keyboard layout not available when using typeText
Keyboard layout not available when using typeText [message #500581] Thu, 26 November 2009 20:15 Go to next message
Lewis Nguyen is currently offline Lewis NguyenFriend
Messages: 5
Registered: November 2009
Junior Member
I needed to use typeText with a comboBox so I added the method in the SWTBot source code. When I use the method I get an error saying "java.lang.IllegalArgumentException: keyboard layout EN_CA not available."
Following instructions from another thread, I used the command "setxkbmap us" and tried using SWTBotPreferences.KEYBOARD_LAYOUT = "EN_US" to change the layout but to no avail.
Using KeyboardLayoutDetector.detectKeyboard() still returns "EN_CA".
I don't want to define my own layout, I just want to use one that is already available.
This happens also when I use typeText for a text box.
I am using Ubuntu through VirtualBox. Does that affect the keyboard layout?
Re: Keyboard layout not available when using typeText [message #500584 is a reply to message #500581] Thu, 26 November 2009 21:22 Go to previous messageGo to next message
Pascal G is currently offline Pascal GFriend
Messages: 157
Registered: July 2009
Senior Member
Lewis Nguyen wrote:
> I needed to use typeText with a comboBox so I added the method in the
> SWTBot source code. When I use the method I get an error saying
> "java.lang.IllegalArgumentException: keyboard layout EN_CA not available."
> Following instructions from another thread, I used the command
> "setxkbmap us" and tried using SWTBotPreferences.KEYBOARD_LAYOUT =
> "EN_US" to change the layout but to no avail.
> Using KeyboardLayoutDetector.detectKeyboard() still returns "EN_CA".
> I don't want to define my own layout, I just want to use one that is
> already available.
> This happens also when I use typeText for a text box.
> I am using Ubuntu through VirtualBox. Does that affect the keyboard layout?

KeyboardLayoutDetector.detectKeyboard() will always return EN_CA if your
locale is EN_CA (like me). By explicitly setting
SWTBotPreferences.KEYBOARD_LAYOUT to EN_US, you avoid the internal call
to KeyboardLayoutDetector.detectKeyboard(). Once
SWTBotPreferences.KEYBOARD_LAYOUT is set, you shouldn't have any problem
using the typeText methods. If it's still not working and you still get
the "Layout not available" error, you should probably post a little
example on what you do so we can help you better.

Hope this helps.
--
Pascal Gélinas | Software Developer
*Nu Echo Inc.*
http://www.nuecho.com/ | http://blog.nuecho.com/

*Because performance matters.*
Re: Keyboard layout not available when using typeText [message #500701 is a reply to message #500584] Fri, 27 November 2009 15:18 Go to previous messageGo to next message
Lewis Nguyen is currently offline Lewis NguyenFriend
Messages: 5
Registered: November 2009
Junior Member
Pascal G wrote on Thu, 26 November 2009 16:22

By explicitly setting
SWTBotPreferences.KEYBOARD_LAYOUT to EN_US, you avoid the internal call
to KeyboardLayoutDetector.detectKeyboard().


Isn't this the code to do so?
SWTBotPreferences.KEYBOARD_LAYOUT = "EN_US";

Here is where I use typeText:

SWTBotShell shell = bot.shell("Import");
shell.activate();
SWTBotPreferences.KEYBOARD_LAYOUT = "EN_US";
bot.comboBoxWithLabel("From directory:").typeText("/home/elewngu/Traces");

I am trying to type the path into the combo of the Import dialog.
You can find it by going to File > Import...
Then from General, select File System
In my test, I am accessing it from somewhere else but it is essentially the same dialog.
Re: Keyboard layout not available when using typeText [message #500709 is a reply to message #500701] Fri, 27 November 2009 15:45 Go to previous messageGo to next message
Pascal G is currently offline Pascal GFriend
Messages: 157
Registered: July 2009
Senior Member
Lewis Nguyen wrote:
> Pascal G wrote on Thu, 26 November 2009 16:22
>> By explicitly setting SWTBotPreferences.KEYBOARD_LAYOUT to EN_US, you
>> avoid the internal call to KeyboardLayoutDetector.detectKeyboard().
>
> Isn't this the code to do so?
> SWTBotPreferences.KEYBOARD_LAYOUT = "EN_US";
>
> Here is where I use typeText:
>
> SWTBotShell shell = bot.shell("Import");
> shell.activate();
> SWTBotPreferences.KEYBOARD_LAYOUT = "EN_US";
> bot.comboBoxWithLabel("From directory:").typeText("/home/elewngu/Traces");
>
> I am trying to type the path into the combo of the Import dialog.
> You can find it by going to File > Import...
> Then from General, select File System
> In my test, I am accessing it from somewhere else but it is essentially
> the same dialog.

This seems ok... and I guess your implementation of typeText() does the
same thing of SWTBotText#typeText().

What is exactly the observed behavior? You get an exception? Nothing is
typed? If you get an exception, what is the error message/stack trace?

--
Pascal Gélinas | Software Developer
*Nu Echo Inc.*
http://www.nuecho.com/ | http://blog.nuecho.com/

*Because performance matters.*
Re: Keyboard layout not available when using typeText [message #500711 is a reply to message #500581] Fri, 27 November 2009 16:00 Go to previous message
Lewis Nguyen is currently offline Lewis NguyenFriend
Messages: 5
Registered: November 2009
Junior Member
It works now...
I honestly don't know why...
I didn't change anything to my code since yesterday but now it's working fine.
Thank you for your help though, I really appreciate it.
Previous Topic:Test Menu Command with Key Press
Next Topic:findControls()
Goto Forum:
  


Current Time: Sun Nov 23 16:08:33 GMT 2014

Powered by FUDForum. Page generated in 0.01749 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software