1、获取上下文
context = driver.current_context
# or
context = driver.context
有关上下文的信息,请参阅 Appium 的混合自动化文档:
https://appium.io/docs/en/writing-running-appium/web/hybrid/index.html
2、获取所有可用于自动化的上下文
contexts = driver.contexts
3、设置当前上下文
webview = driver.contexts[1]
driver.switch_to.context(webview)
# ...
driver.switch_to.context('NATIVE_APP')