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