我有将应用程序置于后台超过 10 分钟的场景,但十分钟后我收到以下错误
org.openqa.selenium.NoSuchSessionException: A session is either terminated or not started (WARNING: The server did not provide any stacktrace information) Command duration or timeout: 0 milliseconds
如果我在后台运行应用程序 9 分钟,它就可以正常工作,没有任何问题
driver.runAppInBackground(Duration.ofMinutes(10));
我尝试使用 capability.setCapability(MobileCapabilityType.NEW_COMMAND_TIMEOUT, 3600);
修复此问题但它也不起作用。
参考appium日志
这对我有用:
在期望功能中添加“newCommandTimeout”:600。
desired_caps = {
"platformName": "Android", # Or iOS, depending on your platform
"deviceName": "iPhone16ProMax",
"app": "path/to/your/app.apk", # Path to your app
"automationName": "UiAutomator2", # Or XCUITest for iOS
"newCommandTimeout": 600 # 10 minutes timeout (600 seconds)
}