Automation 应用程序更改上下文

Automation 应用程序更改上下文,automation,automated-tests,appium,appium-android,Automation,Automated Tests,Appium,Appium Android,我正在用appium自动化一个Android应用程序, 我必须检查gmail里面的一些东西,关闭它,然后回到我的应用程序 在gmail应用程序中,我想在完成后关闭gmail应用程序 为此,我想将上下文更改为gmail,并使用driver.closeApp() 当我询问driver.getContextHandles()时,我得到: “本地应用程序” “WEBVIEW_com.google.android.gm” 当我尝试以下方法时 driver.context((String) driver.g

我正在用appium自动化一个Android应用程序, 我必须检查gmail里面的一些东西,关闭它,然后回到我的应用程序

在gmail应用程序中,我想在完成后关闭gmail应用程序 为此,我想将上下文更改为gmail,并使用driver.closeApp()

当我询问driver.getContextHandles()时,我得到:

  • “本地应用程序”
  • “WEBVIEW_com.google.android.gm”
  • 当我尝试以下方法时

    driver.context((String) driver.getContextHandles().toArray()[1])
    or
    driver.context("WEBVIEW_com.google.android.gm")
    or
    driver.context("WEBVIEW")
    
    我明白了

    Method threw 'io.appium.javA_client.NoSuchContextException' exception