使用移动Chrome和Android应用的测试流程中出现Appium错误:无法将命令代理到远程服务器原始错误:套接字挂断

问题描述

我有以下测试流程:

  1. 打开移动Chrome浏览器
  2. 生成URL身份验证链接
  3. 单击移动Chrome中的链接->打开Android本机应用程序以继续登录会话
  4. 登录会话在一个Android本机移动应用程序中继续,然后打开一个Web视图窗口(不需要上下文切换)

从这一点开始,在应用程序的Web视图的特定页面上,我的代码不断崩溃,并报错 selenium.common.exceptions.WebDriverException: Message: An unkNown server-side error occurred while processing the command. Original error: Could not proxy command to the Remote Server. Original error: socket hang up 此外,日志中还出现500错误at processticksAndRejections

在发生此异常之前,我的测试流程已成功从移动Chrome浏览器切换到本机应用程序,不需要从本机应用程序切换到Web视图的任何上下文(此外,如果这样做,我的代码会崩溃,因为就我试图切换上下文而言)。而且,appium崩溃的页面与以前的网络视图页面相似,可以正常工作。

我已经在测试流程和配置中尝试了大量的这两个选项(刚开始就失败了)。这是到目前为止我最稳定的实现(尽管已经描述了一步,但失败了):

chrome_capabilities = {
    "platformName": "Android","platformVersion": "11.0","deviceName": "Pixel 4","browserName": "chrome"
    }

driver_mobile_chrome = webdriver.Remote('http://localhost:4723/wd/hub',chrome_capabilities)

fpx_url = "https://myurl"
driver_mobile_chrome.get(fpx_url)

#    test code inside a mobile chrome browser comes here

driver_mobile_chrome.close()

#    and here starts new web driver instance and config for a native app to be opened:

native_app_capabilities = {
        "platformName": "Android","app": "C:\\Android_APKs\\android_nav_v3_4_0.apk","appPackage": "com.someapp.package","appActivity": "com.someapp.nav.container.AppContainerActivity","javascriptEnabled": True,"unlockType": "pin","unlockKey": "1111","noreset": true
    }

driver_mobile_app = webdriver.Remote("http://localhost:4723/wd/hub",native_app_capabilities)

#    test-flow continues

如上所述,从那时起,应用程序启动良好,切换到Web视图会传递Web视图的几页,然后在Web视图页面上失败,这在技术上与Web视图页面没有什么不同,此代码成功通过。只要尝试找到此页面的任何元素或与之交互,它都会失败。

我在Windows 10,using Python 3.8,Appium 1.18.0-1,Android Studio with Pixel 4 emulated device,which runs Android 11上运行所有这些东西。

不胜感激!

谢谢!

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)