Hi, I’m doing mobile automation with robot framework & Appium. I want to enter the texts & numbers in my application by pressing the mobile keyboard (Screenshot_01).
TC_01_Login with valid details
Open Application http://localhost:4723/wd/hub platformName=Android deviceName=emulator-5554 app=C:/APK/APK_File_Name.apk automationName=Uiautomator2
sleep 10s
# Skip Button
click element //android.widget.TextView[@text="Skip"]
sleep 5s
# Enter the Name
input text ${Locator_Name} xxxxx
sleep 5s
# Continue Button
click element ${Continue_Button}
sleep 10s
# Enter the Mobile Number
click element ${Locator_Mobile}
sleep 25s
############################# #Try 1
# Click No. 0 from the mobile keyboard
click element //android.widget.LinearLayout[@text="0"]
sleep 1s
############################# #Try 2
# Click No. 0 from the mobile keyboard
PRESS KEYCODE None 0
sleep 2s
#############################
# Next Button
click element ${Next_Button}`
Here, First I tried as “Try 1”, and get the below error;
ValueError: Element locator ‘//android.widget.LinearLayout[@text=“0”]’ did not match any elements.
Then I deleted the first method and tried as “Try 2”. But it closed the application so that I couldn’t complete the scenario.
Please help to solve this issue. Any guidance and advice will be greatly appreciated!
@KonraweePra, In this application, here we used the default keyboard. So, I couldn’t press the keys using the “Click Element” and “Press Keycode” keywords. But I was able to do it by clicking the coordinates.
Here is a sample example, maybe it will be helpful to you.
## Enter the keys
# Click on the space button
AppiumLibrary.click element at coordinates 748 2603
sleep 2s
# Click on the letter "g"
AppiumLibrary.click element at coordinates 718 2262
sleep 2s
# Press No. 0
AppiumLibrary.click element at coordinates 532 2599
sleep 1s
# Press No. 7
AppiumLibrary.click element at coordinates 186 2465
sleep 1s
Sounds like your fairly happy with the approach you fell on which is great Interestingly… did you by chance try one of the Wait Until keywords, over a sleep.
So for example as an approach:
click of input element > wait until element is visible (being the keyboard container for example) > then interact with the buttons > then click of done > wait until page doesn’t not contain element (being the keyboard)
I’d imagine you had used the UIAutomationViewer to find you’re locators for the elements?
Happy to help with a more robust approach, as those coordinates might cause problems across different devices or different orientation.