Target.frontMostApp (). keyboard () could not find key 'N'

I am trying to automate a keyboard using UI Automation.

target.frontMostApp().keyboard().typeString("INTERCOM") 

But I will get this error after the first input of "I"

 target.frontMostApp().keyboard() failed to locate key 'N' Script threw an uncaught JavaScript error: target.frontMostApp().keyboard() failed to locate key 'N' 

I have a localized swedish keyboard.

Does anyone know if this is a mistake or something that I missed?

+4
source share
3 answers

This can help:

 var vKeyboard = target.frontMostApp().keyboard(); vKeyboard.setInterKeyDelay(0.1); vKeyboard.typeString("INTERCOM"); 

By default, this delay is set from 0.03 seconds. This is not enough for your application to update the keys on the keyboard. Increasing this timeout between defining keys for a keyboard method of type String will help you. There is no description for setInterKeyDelay on the UIAKeyboard link page, but this method is available for UIAKeyboard. Also I am not sure about other languages. I don't know if typeString allows typing in other languages, but this 100% works for the English keyboard for iOS 5.x.

+2
source
 try{ target.delay(1); target.frontMostApp().mainWindow().textFields()[0].tap(); target.delay(1); target.frontMostApp().mainWindow().textFields()[0].setValue("INTERCOM"); } catch(err){ target.delay(1); target.frontMostApp().mainWindow().scrollViews()[0].textFields()[0].tap(); target.delay(1); target.frontMostApp().mainWindow().scrollViews()[0].textFields()[0].setValue("INTERCOM"); } 
+1
source

I had this problem too, and I find it typing a line too quickly.

It seems that the key names change depending on the state of the shift.If button. The shift is on, then the key is called "N", if the shift is not on, then it is "n". You will notice how the line is typed that the toggle button is pressed before entering an uppercase letter. Your test tries to press the "N" key before pressing the "Shift" button. This does not affect the first letter of your sentence, because the keyboard has a shift for the first letter.

This also affects the entry of a lowercase character after the uppercase character: the lowercase character can be printed while the shift button is in the process of being pressed.

I use a workaround to enter each letter of a string using separate typeString () methods.

 for (i = 0; i < title.length; i++) { var strChar = title.charAt(i); target.frontMostApp().keyboard().typeString(strChar); } 

The disadvantage of this is that it takes a lot longer to enter the full line.

You can also see the following link, which offers a similar solution, but uses the app.keyboard () method. keys (). tap () for each character of the string instead of the typeString () method. http://jojitsoriano.wordpress.com/2011/06/27/ios-ui-automation-typing-a-string-in-a-uiatextfield/

-1
source

Source: https://habr.com/ru/post/1411941/


All Articles