chromedriver的版本不对 应该装 模拟器或者真机内置的浏览器,输入一下网址可以查看版本:https://liulanmi.com/labs/core.html
print(self.driver.contexts) # NATIVE_APP 说明没有开启webview开关 如果是 类似于['NATIVE_APP','WEBVIEW_com.ekwing.students']说明开启了 webview
contexts = self.driver.contexts
print(contexts)
# self.driver.switch_to
print("切换为H5的内容")
self.driver.switch_to.context("WEBVIEW_com.ekwing.students")
# el1 = self.driver.find_element_by_class_name("back_btn")
self.find_element_and_click(self.__back_button)
# print(el1)
# el1.click()
print("切换为之前的 ")
print(self.driver.switch_to.context("NATIVE_APP"))
# 同意的按钮
__agree_radio_button = (By.ID, "com.ekwing.students:id/checkbox_pri")
self.find_element_and_click(__agree_radio_button)
参考连接:https://www.cnblogs.com/my_captain/p/12796590.html
在使用Appium进行自动化测试时遇到切换上下文的错误,原因是Chromedriver版本与模拟器或真机内置浏览器版本不匹配。解决方案是访问网址https://liulanmi.com/labs/core.html查询正确版本,并根据设备浏览器版本安装对应的Chromedriver。参考文章:https://www.cnblogs.com/my_captain/p/12796590.html
491

被折叠的 条评论
为什么被折叠?



