appium/java-client

Android - Error when trying to use sendKey or clear function on WebElement obtained with driver.findElement(new AppiumBy.ByAndroidViewTag("myTag"));

darcheville opened this issue · 1 comments

Hello,

I get an error when i try to use sendKey or clear functions on WebElement obtained with driver.findElement(new AppiumBy.ByAndroidViewTag("myTag"));

 WebElement network = driver.findElement(new AppiumBy.ByAndroidViewTag("myTag")); => ok, no error
  network.click(); => ok, no error
  network.sendKeys("test"); or network.clear(); => not ok, i get an error 

=> Stack trace
Exception in thread "main" org.openqa.selenium.InvalidElementStateException: Could not perform sendKeys/setValueImmediate action on the element 0e3f8f3e-5e28-414b-93f0-0809452d52f2
Build info: version: '4.21.0', revision: '79ed462ef4'
System info: os.name: 'Mac OS X', os.arch: 'aarch64', os.version: '14.1.1', java.version: '22.0.1'
Driver info: io.appium.java_client.android.AndroidDriver
Command: [ac783605-bf94-4b80-b61f-ce1b09aae574, sendKeysToElement {id=0e3f8f3e-5e28-414b-93f0-0809452d52f2, value=[Ljava.lang.CharSequence;@3b77a04f}]
Element: [[AndroidDriver: on ANDROID (ac783605-bf94-4b80-b61f-ce1b09aae574)] -> -android viewtag: myTag]
Session ID: ac783605-bf94-4b80-b61f-ce1b09aae574
at java.base/jdk.internal.reflect.DirectConstructorHandleAccessor.newInstance(DirectConstructorHandleAccessor.java:62)
at java.base/java.lang.reflect.Constructor.newInstanceWithCaller(Constructor.java:502)
at java.base/java.lang.reflect.Constructor.newInstance(Constructor.java:486)
at org.openqa.selenium.remote.ErrorCodec.decode(ErrorCodec.java:167)
at org.openqa.selenium.remote.codec.w3c.W3CHttpResponseCodec.decode(W3CHttpResponseCodec.java:138)
at org.openqa.selenium.remote.codec.w3c.W3CHttpResponseCodec.decode(W3CHttpResponseCodec.java:50)
at org.openqa.selenium.remote.HttpCommandExecutor.execute(HttpCommandExecutor.java:190)
at io.appium.java_client.remote.AppiumCommandExecutor.execute(AppiumCommandExecutor.java:237)
at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:518)
at org.openqa.selenium.remote.RemoteWebElement.execute(RemoteWebElement.java:223)
at org.openqa.selenium.remote.RemoteWebElement.sendKeys(RemoteWebElement.java:110)

Process finished with exit code 1

Please help,
Thanks and Regards

Please share the Appium Server logs as well.

It seems that you are trying to use the locator strategy that is only supported by Appium Espresso driver.
In my observation, sendKeys and clear work on the Android elements of class android.widget.TextView

Please check the class of network element where you are trying to call sendKeys() and clear() and see if you still get this error if you locate an element of class android.widget.TextView