1.'''原生切换到webview'''
def cons(self):
'''强制等待'''
sleep(3)
d = self.driver # 获取驱动
list = d.contexts # 所有的上下文对象
print(list)
for con in list:
if con.lower().startswith('webview'): # 如果以webview开头
sleep(2)
d._switch_to.context(con)
print('切换成功')
print(d.context)
2.”’webview切换到原生”’
def contwo(self):
sleep(3)
d = self.driver # 获取驱动
list = d.contexts # 所有的上下文对象
sleep(3)
for con in list:
if con.lower().startswith(‘native’): # 如果以webview开头
d._switch_to.context(con)
print(d.context)