appium 切换上下文的时候报错

在使用Appium进行自动化测试时遇到切换上下文的错误,原因是Chromedriver版本与模拟器或真机内置浏览器版本不匹配。解决方案是访问网址https://liulanmi.com/labs/core.html查询正确版本,并根据设备浏览器版本安装对应的Chromedriver。参考文章:https://www.cnblogs.com/my_captain/p/12796590.html

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

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

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值