Reputation: 21
I'm trying to input URL on Safari on real iPhone device but got this error
InvalidElementStateException: Message: Error Domain=com.facebook.WebDriverAgent Code=1 "The on-screen keyboard must be present to send keys" UserInfo={NSLocalizedDescription=The on-screen keyboard must be present to send keys}
This is my code
**** Settings ****
Library Selenium2Library
Library Collections
Library requests
Library AppiumLibrary
**** Test Cases ****
Test_case_sample
Open application http://127.0.0.1:4723/wd/hub alias=Phone platformName=iOS platformVersion=13.3 deviceName=iPhone bundleId=com.apple.mobilesafari
... udid=********************** nativeWebTap=true automationName=XCUITest noReset=false wdaLocalPort=8145 useNewWDA=true
AppiumLibrary.Input Text xpath=//XCUIElementTypeButton[@name="URL"] https://www.google.com/
Hide Keyboard Go
1.I don't have any third party keyboard installed.
2.I don't want to use browserName=Safari because I want to verify the URL link.
3.Input problem only happen on Safari.
iPhone 7 iOS 13.3 Appium 1.17.1-1
Can anyone help me out here.
Upvotes: 2
Views: 2103
Reputation: 630
The issue was fixed in my case by clicking on the nearby text label related to input element before setting the text value. I guess it is due to the input element's value can be added by scanning as well in this app.
Upvotes: 0
Reputation: 445
This seems to be a know issue with appium. Here is a thread talking about it: https://github.com/appium/appium/issues/10418
As for me, I fixed the issue by clicking on the element before sending to send keys to it.
Upvotes: 2
Reputation: 41
Replace the
AppiumLibrary.Input Text xpath=//XCUIElementTypeButton[@name="URL"] https://www.google.com/
with following three lines:
AppiumLibrary.Click Element xpath=//XCUIElementTypeOther[@name="Address"]
That seems to be the address element you can click. After you you click it, the element turns to text field. But at least as i tried it, the xpath does not get read quick enough, and the test fails unless we wait for it to become visible:
AppiumLibrary.Wait Until Element Is Visible xpath=//XCUIElementTypeTextField[@name="URL"]
And now input the text:
AppiumLibrary.Input Text xpath=//XCUIElementTypeTextField[@name="URL"] https://www.google.com/
Should you have issues with the script failing to find the first element, then you might need a Wait Until Element Is Visible
there as well.
Upvotes: 0