Issue
Input action should happen like thisMobile Automation: I have a a scenario where i have to send keystrokes(inputs) from SoftKeyboard of an android device (like inputs from a real User). I tried with KeyEvent, SendKeys, androidkeycode, adb Shell input, Keys. Everything works fine, but i do not see any character pressed from a soft keyboard. Pls, help me to get solution for this.!!
Solution
The need: You need to simulate a press on the on-screen keyboard (using driver.tap()
)
The problem: Cannot get the Xpath or ID's of a on screen keyboard which puts us in a difficult situation.
Since i've struggled with this same problem in the past, i will advise you to create a function that calculate where each Key is located and press on it using the coordinates.
To be more clear:
- Get the coordinates of lowest element you can find -> the keyboard itself is below it -> we can now know the height of the keyboard.
- get the width of the screen
now, lets say you have a total of 4 rows(first row is q,w,e..) so we will divide the height by 4. lets say you want a key from the first row which has 10 keys total, now dived the screen width by 10.
now you need to map each key to its location in a row. After that, call this function for each key you want to press.
I understand that it's ugly, and you will struggle with it a bit, but I don't know another solution to your problem.
Answered By - David Ep
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.