***问题:在用Appium做APP自动化时,会遇到搜索页面无搜索按钮,输入内容后,需要回车进行搜索;
使用self._driver.press_keycode(66) ,发现页面完全无反应;我使用的是mumu模拟器,手机被appium控制后,无法弹出键盘;
***解决:使用命令:adb shell ime list -s 查看当前手机安装的输入法;输入回车通常做法调起键盘,再执行self._driver.press_keycode(66),但是由于appium无法调起手机的输入法,这时候需要下载安装搜狗输入法,安装完成后;
具体思路是首先使用 adb shell ime set com.sohu.inputmethod.sogou/.SogouIME 调起搜狗输入法
然后输入回车键
最后再调起appium的输入法;
脚本如下:
# 调起搜狗输入法
os.system('adb shell ime set com.sohu.inputmethod.sogou/.SogouIME')
time.sleep(2)
# 输入回车键
self._driver.press_keycode(66)
time.sleep(2)
# 最后调起appiu的输入法
os.system('adb shell ime set io.appium.settings/.UnicodeIME')