在测试类 A 中启动 app 完成测试后(driver 写在一个专门写参数的模块里,没有放在 setup()中),再 teardown 中 driver.quit()关闭 app,之后继续运行测试类 B,此时报错 A session is either terminated or not started 。
直接在测试类 B 的 setup()中写上 self.driver = driver 或者不写都一样报上面的错误
appium 日志:
[AndroidBootstrap] [BOOTSTRAP LOG] [debug] Finding '//android.widget.Button[@text='账户退出']' using 'XPATH' with the contextId: '' multiple: false
[AndroidBootstrap] [BOOTSTRAP LOG] [debug] Returning result: {"value":"Could not find an element using supplied strategy. ","status":7}
[AndroidBootstrap] Received command result from bootstrap
[HTTP] <-- POST /wd/hub/session/37c57813-ef00-4ae3-aa3d-82e7497a88b9/element 500 19 ms - 164
[HTTP] --> DELETE /wd/hub/session/37c57813-ef00-4ae3-aa3d-82e7497a88b9 {}
[MJSONWP] Calling AppiumDriver.deleteSession() with args: ["37c57813-ef00-4ae3-aa3d-82e7497a88b9"]
[BaseDriver] Event 'quitSessionRequested' logged at 1504771567658 (16:06:07 GMT+0800 (中国标准时间))
[AndroidDriver] Shutting down Android driver
[AndroidDriver] Stopping chromedriver for context WEBVIEW_com.changhong.cloudtrip
[Chromedriver] Changed state to 'stopping'
[JSONWP Proxy] Proxying [DELETE /] to [DELETE http://127.0.0.1:8000/wd/hub/session/7265d1da25b7e58a0f1adfe64b33c6c4] with no body
[JSONWP Proxy] Got response with status 200: "{\"sessionId\":\"7265d1da25b7e58a0f1adfe64b33c6c4\",\"status\":0,\"value\":null}"
[Chromedriver] Changed state to 'stopped'
[AndroidDriver] Resetting IME to io.appium.android.ime/.UnicodeIME
[ADB] Getting connected devices...
[ADB] 1 device(s) connected
[ADB] Running 'D:\android-sdk\platform-tools\adb.exe' with args: ["-P",5037,"-s","127.0.0.1:62001","shell","ime","set","io.appium.android.ime/.UnicodeIME"]
[ADB] Getting connected devices...
[ADB] 1 device(s) connected
[ADB] Running 'D:\android-sdk\platform-tools\adb.exe' with args: ["-P",5037,"-s","127.0.0.1:62001","shell","am","force-stop","com.changhong.cloudtrip"]
[ADB] Pressing the HOME button
[ADB] Getting connected devices...
[ADB] 1 device(s) connected
[ADB] Running 'D:\android-sdk\platform-tools\adb.exe' with args: ["-P",5037,"-s","127.0.0.1:62001","shell","input","keyevent",3]
[AndroidBootstrap] Sending command to android: {"cmd":"shutdown"}
[AndroidBootstrap] [BOOTSTRAP LOG] [debug] Got data from client: {"cmd":"shutdown"}
[AndroidBootstrap] [BOOTSTRAP LOG] [debug] Got command of type SHUTDOWN
[AndroidBootstrap] [BOOTSTRAP LOG] [debug] Returning result: {"value":"OK, shutting down","status":0}
[AndroidBootstrap] [BOOTSTRAP LOG] [debug] Closed client connection
[AndroidBootstrap] [UIAUTO STDOUT] INSTRUMENTATION_STATUS: numtests=1
[AndroidBootstrap] [UIAUTO STDOUT] INSTRUMENTATION_STATUS: stream=.
[AndroidBootstrap] [UIAUTO STDOUT] INSTRUMENTATION_STATUS: id=UiAutomatorTestRunner
[AndroidBootstrap] [UIAUTO STDOUT] INSTRUMENTATION_STATUS: test=testRunServer
[AndroidBootstrap] [UIAUTO STDOUT] INSTRUMENTATION_STATUS: class=io.appium.android.bootstrap.Bootstrap
[AndroidBootstrap] [UIAUTO STDOUT] INSTRUMENTATION_STATUS: current=1
[AndroidBootstrap] [UIAUTO STDOUT] INSTRUMENTATION_STATUS_CODE: 0
[AndroidBootstrap] [UIAUTO STDOUT] INSTRUMENTATION_STATUS: stream=
[AndroidBootstrap] [UIAUTO STDOUT] Test results for WatcherResultPrinter=.
[AndroidBootstrap] [UIAUTO STDOUT] Time: 607.044
[AndroidBootstrap] [UIAUTO STDOUT] OK (1 test)
[AndroidBootstrap] [UIAUTO STDOUT] INSTRUMENTATION_STATUS_CODE: -1
[AndroidBootstrap] Received command result from bootstrap
[UiAutomator] Shutting down UiAutomator
[UiAutomator] Moving to state 'stopping'
[UiAutomator] UiAutomator shut down normally
[UiAutomator] Moving to state 'stopped'
[ADB] Attempting to kill all uiautomator processes
[ADB] Getting all processes with uiautomator
[ADB] Getting connected devices...
[ADB] 1 device(s) connected
[ADB] Running 'D:\android-sdk\platform-tools\adb.exe' with args: ["-P",5037,"-s","127.0.0.1:62001","shell","ps"]
[ADB] No uiautomator process found to kill, continuing...
[UiAutomator] Moving to state 'stopped'
[Logcat] Stopping logcat capture
[ADB] Getting connected devices...
[ADB] 1 device(s) connected
[ADB] Running 'D:\android-sdk\platform-tools\adb.exe' with args: ["-P",5037,"-s","127.0.0.1:62001","shell","am","force-stop","io.appium.unlock"]
[AndroidDriver] Not cleaning generated files. Add clearSystemFiles
capability if wanted.
[Appium] Removing session 37c57813-ef00-4ae3-aa3d-82e7497a88b9 from our master session list
[BaseDriver] Event 'quitSessionFinished' logged at 1504771574330 (16:06:14 GMT+0800 (中国标准时间))
[MJSONWP] Received response: null
[MJSONWP] But deleting session, so not returning
[MJSONWP] Responding to client with driver.deleteSession() result: null
[HTTP] <-- DELETE /wd/hub/session/37c57813-ef00-4ae3-aa3d-82e7497a88b9 200 6674 ms - 76
[HTTP] --> GET /wd/hub/session/37c57813-ef00-4ae3-aa3d-82e7497a88b9/window/current/size {}
[HTTP] <-- GET /wd/hub/session/37c57813-ef00-4ae3-aa3d-82e7497a88b9/window/current/size 404 2 ms - 131
[HTTP] --> DELETE /wd/hub/session/37c57813-ef00-4ae3-aa3d-82e7497a88b9 {}
[HTTP] <-- DELETE /wd/hub/session/37c57813-ef00-4ae3-aa3d-82e7497a88b9 404 2 ms - 131