Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

InvalidElementStateException on SecureTextField is not ready for a text input on iOS/XCUITest #1386

Open
alyshakt opened this issue Aug 27, 2020 · 12 comments

Comments

@alyshakt
Copy link

alyshakt commented Aug 27, 2020

Description

Just recently unable to enter text into a XCUIElementTypeSecureTextField on iOS as I consistently get InvalidElementStateException: Error Domain=com.facebook.WebDriverAgent Code=1 "'"passwordTextField" SecureTextField' is not ready for a text input. Neither the accessibility element itself nor its accessible descendants have the input focus

I have already tried different identifiers such as xpath vs className, name, everything.
I have already tried setting hardware keyboard to true and/or false.
I have already tried setting different sendKeyStrategy options.
I have already tried getKeyboard() before and after interacting with the field.

This is a sudden break on very old regression tests, without changes to source test code or source app code for context.

Steps:

  1. Define element any way possible. (Have tried by className = "XCUIElementTypeSecureTextField", name= "specificID", xpath = "//XCUIElementTypeTable/XCUIElementTypeCell/XCUIElementTypeSecureTextField" and combination of driver find bys to no avail)
  2. sendKeys into the SecureTextField. Also have tried many ways including clearing, clicking into the field, directly sending keys from keyboard- to no avail.
  3. All interactions with the field produce the InvalidElementStateException

Environment

``

  • Java client build version or git revision if you use some snapshot: 7.3.0
  • Appium server version or git revision if you use some snapshot: 1.18.1
  • Desktop OS/version used to run Appium if necessary: App Version: 1.18.0 Electron: 7.2.4
  • Node.js version (unless using Appium.app|exe) or Appium CLI or Appium.app|exe: Node.js: 12.8.1
  • Mobile platform/version under test: iOS 12.4+ (occurring also on 13.1, 13.4, 13.6)
  • Real device or emulator/simulator: Simulator

Details

Please provide more details, if necessary.

Code To Reproduce Issue [ Good To Have ]

@FindBy(name = "passwordTextField") private WebElement passwordTextField;
public void enterFirstPassword(String password){ ((IOSDriver)driver).getKeyboard(); passwordTextField.clear(); passwordTextField.sendKeys(password); ((IOSDriver)driver).hideKeyboard(HideKeyboardStrategy.PRESS_KEY,"next"); }

Exception Stacktraces

org.openqa.selenium.InvalidElementStateException: Error Domain=com.facebook.WebDriverAgent Code=1 "'"passwordTextField" SecureTextField' is not ready for a text input. Neither the accessibility element itself nor its accessible descendants have the input focus" UserInfo={NSLocalizedDescription='"passwordTextField" SecureTextField' is not ready for a text input. Neither the accessibility element itself nor its accessible descendants have the input focus}
Build info: version: '3.141.59', revision: 'e82be7d358', time: '2018-11-14T08:17:03'
System info: host: 'MVADMINs-MacBook-Pro-2.local', ip: 'fe80:0:0:0:14cc:83e1:88d:25cd%en0', os.name: 'Mac OS X', os.arch: 'x86_64', os.version: '10.15.6', java.version: '11.0.7'
Driver info: io.appium.java_client.ios.IOSDriver
Capabilities {app: src/main/resources/app/ios/..., autoAcceptAlerts: false, autoDismissAlerts: false, automationName: XCUITest, browserName: , clearSystemFiles: true, connectHardwareKeyboard: false, databaseEnabled: false, deviceName: iPhone 7, ensureFreshSimulatorCreation: true, fullReset: true, isHeadless: false, javascriptEnabled: true, locationContextEnabled: false, networkConnectionEnabled: false, newCommandTimeout: 15, platform: MAC, platformName: iOS, platformVersion: 13.1, sendKeyStrategy: oneByOne, shouldUseSingletonTestManager: false, takesScreenshot: true, udid: 64D22ED2-2DA1-47AB-9CE1-4E7..., webStorageEnabled: false}
Session ID: 06a2e55d-4037-4cdc-8510-32df5e421555

	at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
	at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
	at java.base/jdk.internal.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
	at java.base/java.lang.reflect.Constructor.newInstance(Constructor.java:490)
	at org.openqa.selenium.remote.http.W3CHttpResponseCodec.createException(W3CHttpResponseCodec.java:187)
	at org.openqa.selenium.remote.http.W3CHttpResponseCodec.decode(W3CHttpResponseCodec.java:122)
	at org.openqa.selenium.remote.http.W3CHttpResponseCodec.decode(W3CHttpResponseCodec.java:49)
	at org.openqa.selenium.remote.HttpCommandExecutor.execute(HttpCommandExecutor.java:158)
	at io.appium.java_client.remote.AppiumCommandExecutor.execute(AppiumCommandExecutor.java:239)
	at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:552)
	at io.appium.java_client.DefaultGenericMobileDriver.execute(DefaultGenericMobileDriver.java:41)
	at io.appium.java_client.AppiumDriver.execute(AppiumDriver.java:1)
	at io.appium.java_client.ios.IOSDriver.execute(IOSDriver.java:1)
	at org.openqa.selenium.remote.RemoteWebElement.execute(RemoteWebElement.java:285)
	at io.appium.java_client.DefaultGenericMobileElement.execute(DefaultGenericMobileElement.java:45)
	at io.appium.java_client.MobileElement.execute(MobileElement.java:1)
	at io.appium.java_client.ios.IOSElement.execute(IOSElement.java:1)
	at org.openqa.selenium.remote.RemoteWebElement.sendKeys(RemoteWebElement.java:106)

Link To Appium Logs

https://gist.github.com/alyshakt/365996aac3dd47ee38feded21c512070

@groverinho
Copy link

I have the same issue when I try to send keys to an input field
Screen Shot 2020-09-03 at 11 38 43 AM

@GeorgeXCV
Copy link

This isn't specific to the Java client. Seeing the same issue on a JavaScript project, also old regression test that has been passing fine for a long time until recently.

Error:

Error: Error Domain=com.facebook.WebDriverAgent Code=1 "'"MnemonicTextView.recoveryPhrase" Other' is not ready for a text input. Neither the accessibility element itself nor its accessible descendants have the input focus" UserInfo={NSLocalizedDescription='"MnemonicTextView.recoveryPhrase" Other' is not ready for a text input. Neither the accessibility element itself nor its accessible descendants have the input focus}

Logs:

020-09-04 01:19:09:907 - [HTTP] {"using":"accessibility id","value":"MnemonicTextView.recoveryPhrase"}
2020-09-04 01:19:09:907 - [debug] [MJSONWP (bb9b0596)] Calling AppiumDriver.findElement() with args: ["accessibility id","MnemonicTextView.recoveryPhrase","bb9b0596-b109-4260-af4e-0d41914707e4"]
2020-09-04 01:19:09:908 - [debug] [XCUITest] Executing command 'findElement'
2020-09-04 01:19:09:908 - [debug] [BaseDriver] Valid locator strategies for this request: xpath, id, name, class name, -ios predicate string, -ios class chain, accessibility id
2020-09-04 01:19:09:908 - [debug] [BaseDriver] Waiting up to 10000 ms for condition
2020-09-04 01:19:09:908 - [debug] [WD Proxy] Matched '/element' to command name 'findElement'
2020-09-04 01:19:09:908 - [debug] [WD Proxy] Proxying [POST /element] to [POST http://127.0.0.1:8406/session/C23C8F0E-1445-4252-A20E-474006F29CB6/element] with body: {"using":"accessibility id","value":"MnemonicTextView.recoveryPhrase"}
2020-09-04 01:19:10:032 - [debug] [WD Proxy] Got response with status 200: {"value":{"ELEMENT":"21000000-0000-0000-BF10-000000000000","element-6066-11e4-a52e-4f735466cecf":"21000000-0000-0000-BF10-000000000000"},"sessionId":"C23C8F0E-1445-4252-A20E-474006F29CB6"}
2020-09-04 01:19:10:032 - [debug] [MJSONWP (bb9b0596)] Responding to client with driver.findElement() result: {"element-6066-11e4-a52e-4f735466cecf":"21000000-0000-0000-BF10-000000000000","ELEMENT":"21000000-0000-0000-BF10-000000000000"}
2020-09-04 01:19:10:032 - [HTTP] <-- POST /wd/hub/session/bb9b0596-b109-4260-af4e-0d41914707e4/element 200 125 ms - 199
2020-09-04 01:19:10:032 - [HTTP] 
2020-09-04 01:19:10:127 - [HTTP] --> POST /wd/hub/session/bb9b0596-b109-4260-af4e-0d41914707e4/touch/perform
2020-09-04 01:19:10:127 - [HTTP] {"actions":[{"action":"tap","options":{"element":"21000000-0000-0000-BF10-000000000000"}}]}
2020-09-04 01:19:10:128 - [debug] [MJSONWP (bb9b0596)] Calling AppiumDriver.performTouch() with args: [[{"action":"tap","options":{"element":"21000000-0000-0000-BF10-000000000000"}}],"bb9b0596-b109-4260-af4e-0d41914707e4"]
2020-09-04 01:19:10:128 - [debug] [XCUITest] Executing command 'performTouch'
2020-09-04 01:19:10:128 - [debug] [XCUITest] Received the following touch action: tap(options={"element":"21000000-0000-0000-BF10-000000000000"})
2020-09-04 01:19:10:140 - [debug] [WD Proxy] Proxying [POST /wda/touch/perform] to [POST http://127.0.0.1:8406/session/C23C8F0E-1445-4252-A20E-474006F29CB6/wda/touch/perform] with body: {"actions":[{"action":"tap","options":{"element":"21000000-0000-0000-BF10-000000000000"}}]}
2020-09-04 01:19:10:397 - [debug] [WD Proxy] Got response with status 200: {"value":null,"sessionId":"C23C8F0E-1445-4252-A20E-474006F29CB6"}
2020-09-04 01:19:10:397 - [debug] [MJSONWP (bb9b0596)] Responding to client with driver.performTouch() result: null
2020-09-04 01:19:10:398 - [HTTP] <-- POST /wd/hub/session/bb9b0596-b109-4260-af4e-0d41914707e4/touch/perform 200 270 ms - 76
2020-09-04 01:19:10:398 - [HTTP] 
2020-09-04 01:19:10:472 - [HTTP] --> POST /wd/hub/session/bb9b0596-b109-4260-af4e-0d41914707e4/element/21000000-0000-0000-BF10-000000000000/value
2020-09-04 01:19:10:472 - [HTTP] {"text":"hold panel make absent soccer quick pink brand race tortoise verify nature"}
2020-09-04 01:19:10:473 - [debug] [MJSONWP (bb9b0596)] Calling AppiumDriver.setValue() with args: ["hold panel make absent soccer quick pink brand race tortoise verify nature","21000000-0000-0000-BF10-000000000000","bb9b0596-b109-4260-af4e-0d41914707e4"]
2020-09-04 01:19:10:473 - [debug] [XCUITest] Executing command 'setValue'
2020-09-04 01:19:10:474 - [debug] [WD Proxy] Matched '/element/21000000-0000-0000-BF10-000000000000/value' to command name 'setValue'
2020-09-04 01:19:10:474 - [debug] [Protocol Converter] Added 'text' property "hold panel make absent soccer quick pink brand race tortoise verify nature" to 'setValue' request body
2020-09-04 01:19:10:474 - [debug] [WD Proxy] Proxying [POST /element/21000000-0000-0000-BF10-000000000000/value] to [POST http://127.0.0.1:8406/session/C23C8F0E-1445-4252-A20E-474006F29CB6/element/21000000-0000-0000-BF10-000000000000/value] with body: {"value":["h","o","l","d"," ","p","a","n","e","l"," ","m","a","k","e"," ","a","b","s","e","n","t"," ","s","o","c","c","e","r"," ","q","u","i","c","k"," ","p","i","n","k"," ","b","r","a","n","d"," ","r","a","c","e"," ","t","o","r","t","o","i","s","e"," ","v","e","r","i","f","y"," ","n","a","t","u","r","e"],"text":"hold panel make absent soccer quick pink brand race tortoise verify nature"}
2020-09-04 01:19:11:874 - [WD Proxy] Got response with status 400: {"value":{"error":"invalid element state","message":"Error Domain=com.facebook.WebDriverAgent Code=1 \"'\"MnemonicTextView.recoveryPhrase\" Other' is not ready for a text input. Neither the accessibility element itself nor its accessible descendants have the input focus\" UserInfo={NSLocalizedDescription='\"MnemonicTextView.recoveryPhrase\" Other' is not ready for a text input. Neither the accessibility element itself nor its accessible descendants have the input focus}","traceback":""},"sessionId":"C23C8F0E-1445-4252-A20E-474006F29CB6"}
2020-09-04 01:19:11:875 - [debug] [W3C] Matched W3C error code 'invalid element state' to InvalidElementStateError
2020-09-04 01:19:11:903 - [debug] [MJSONWP (bb9b0596)] Encountered internal error running command: InvalidElementStateError: Error Domain=com.facebook.WebDriverAgent Code=1 "'"MnemonicTextView.recoveryPhrase" Other' is not ready for a text input. Neither the accessibility element itself nor its accessible descendants have the input focus" UserInfo={NSLocalizedDescription='"MnemonicTextView.recoveryPhrase" Other' is not ready for a text input. Neither the accessibility element itself nor its accessible descendants have the input focus}
2020-09-04 01:19:11:903 - [debug] [MJSONWP (bb9b0596)]     at errorFromW3CJsonCode (/usr/local/.browserstack/appium_1.18.0_bstack/node_modules/appium-base-driver/lib/protocol/errors.js:780:25)
2020-09-04 01:19:11:904 - [debug] [MJSONWP (bb9b0596)]     at ProxyRequestError.getActualError (/usr/local/.browserstack/appium_1.18.0_bstack/node_modules/appium-base-driver/lib/protocol/errors.js:663:14)
2020-09-04 01:19:11:904 - [debug] [MJSONWP (bb9b0596)]     at JWProxy.command (/usr/local/.browserstack/appium_1.18.0_bstack/node_modules/appium-base-driver/lib/jsonwp-proxy/proxy.js:279:8)
2020-09-04 01:19:11:904 - [debug] [MJSONWP (bb9b0596)]     at process._tickCallback (internal/process/next_tick.js:68:7)
2020-09-04 01:19:11:904 - [HTTP] <-- POST /wd/hub/session/bb9b0596-b109-4260-af4e-0d41914707e4/element/21000000-0000-0000-BF10-000000000000/value 500 1432 ms - 508

@GeorgeXCV
Copy link

Downgrading to Appium 1.17.0 has resolved the issue for me. Can we move this issue over to the main repo? @mykola-mokhnach

@mykola-mokhnach
Copy link
Contributor

@GeorgeXCV Please attach the page source output. It could be the page has multiple elements with duplicated identifiers

@GeorgeXCV
Copy link

@mykola-mokhnach The iOS page that had this issue has two elements only, text input and a button. Like the OP, the regression test and actual UI hasn't changed in months. Downgrading to Appium 1.17.0 worked for me.

@mykola-mokhnach
Copy link
Contributor

Sorry, I cannot help nothing without the details. Also, you won't be able to use older Appium versions while Apple does new iOS releases.

@GeorgeXCV
Copy link

What details? I have never heard of page source output in the context of an iOS Application. Logs show one element is found. Downgrading is what fixed the issue, I believe its a bug with Appium.

@NirBY
Copy link

NirBY commented Sep 7, 2020

Having same issue:

  • Appium V1.18.1
  • Real Device - iPhone 8, IOS 13.7
  • Selector used - MobileBy.iOSNsPredicateString("type == 'XCUIElementTypeTextField' AND value == 'Phone'")

Page Source including"mobile: source" - 20200906084105_872.txt

Appium Log - appiumServeriPhone8.log

@mykola-mokhnach
Copy link
Contributor

@NirBY Try W3C actions to send text as a possible workaround. You could also replace local WDA source with appium/WebDriverAgent#379. I have disabled focus check there, so it makes sense to check if that helps.

@skmurug
Copy link

skmurug commented Sep 7, 2020

appium/WebDriverAgent#379 This works. I have tested with my test app and I am able to type to StaticTextField which was working fine with 1.17.1 and stopped when updated to 1.18.1

@mykola-mokhnach - Thanks for the quick fix.

@NirBY
Copy link

NirBY commented Sep 8, 2020

@mykola-mokhnach used WebDriverAgent 11.7 since I have xcode 11.7 (I have just replaced all files in /usr/local/lib/node_modules/appium/node_modules/appium-webdriveragent).
It didnt worked, Appium log - appiumServeriPhone8.log.txt

Note:

  • Running it manually worked fine
  • Also try removing WebDriverAgent & restart device, it wasn't helpful.

@NirBY
Copy link

NirBY commented Sep 10, 2020

Thank you @mykola-mokhnach. W3C actions worked for me. while waiting for the release of the new WebDriverAgent.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants