appium-uiautomator2-server icon indicating copy to clipboard operation
appium-uiautomator2-server copied to clipboard

"Cannot set the element to...Did you interact with the correct element?" error

Open canfeit opened this issue 5 years ago • 1 comments

https://github.com/appium/appium-uiautomator2-server/blob/1786d0c84d75fff79fde5255be0a9ec6ea222e42/app/src/main/java/io/appium/uiautomator2/handler/SendKeysToElement.java#L67

Multiple focused elements exist on the same page,findElement(focused(true)) can't find the right element. I got "Cannot set the element to...Did you interact with the correct element?" error.

Whether the findElement here should be called in combination with clazz("EditText") and focused(true)?

canfeit avatar Apr 23 '19 07:04 canfeit

My solution is that:

  1. Install Yosemite on test phone. https://github.com/AirtestProject/Airtest/blob/master/airtest/core/android/static/apks/Yosemite.apk
  2. adb shell ime set com.netease.nie.yosemite/.ime.ImeService
  3. adb shell settings get secure default_input_method # save the default input method to a variable
  4. adb shell am broadcast -a ADB_INPUT_TEXT --es msg '你好' # set text to your input after it is clicked
  5. adb shell ime set <defaultIme> # restore the default input method

just use shelljs to execute the commands in code to walk around the cannot use setValue issue.

wesley-firewalla avatar May 08 '19 02:05 wesley-firewalla