appium上下文切换、webview调试以及chromedriver/键盘等报错问题解决
1、切换上下文
contexts = self.driver.contexts #获取全部的上下文 self.driver.switch_to.context(contexts[-1]) #切换到webview页面
driver.switch_to.context(contexts[0]) #切换回Native页面
2、webview调试
前提条件:
1、手机与电脑连接,手机开启usb调试模式
2、可kexueshangwang
3、打开http://chromedriver.storage.googleapis.com/index.html
在启动参数加上:
"chromedriverExecutable":r"D:\appiumchromedriver\chromedriver.exe"
5、键盘输入账号密码等后,由于没有收起键盘导致无法定位到搜索框或者登录按钮,报错
尝试使用网上的self.driver.hide_keyboard(),但还是不行,于是选择使用keyword,执行:
os.popen("adb shell input keyevent 66")
进行模拟输入法里的搜索按钮,已实验可解决问题