Solution:
case中加了sleep后,可能会报这个错。
查看appium server log中有该打印:
Shutting down because we waited 60 seconds for a command
Closing session, cause was 'New Command Timeout of 60 seconds expired. Try customizing the timeout using the
Appium在没有收到下一个命令时,默认超时时间是60s,超时后应用将会自动关闭session,所以你接下来的所有操作都将失败。(Android和iOS通用)
capabilities = {
‘automationName’: ‘UIAutomator2’,
#可以通过newcommandtimeout将超时时间改长,这样就解决了该问题!!
#超时时间可按照实际情况自定义!
‘newCommandTimeout’: “2000”,
‘unicodeKeyboard’: True,
‘resetKeyboard’: True,
‘noSign’: True
}
host = “http://localhost:4723/wd/hub”
driver = webdriver.Remote(host, capabilities)