切换到 h5 没有定位元素,日志如下,最后脚本报错

raise wde
selenium.common.exceptions.WebDriverException: Message: no such session
  (Driver info: chromedriver=2.21.371459 (36d3d07f660ff2bc1bf28a75d1cdabed0983e7c4),platform=Mac OS X 10.12.1 x86_64)



["NATIVE_APP","WEBVIEW_so.dian.operatordebug","WEBVIEW_com.vphone.launcher"]
[debug] [AndroidDriver] Connecting to chrome-backed webview context 'WEBVIEW_so.dian.operatordebug'
[debug] [Chromedriver] Changed state to 'starting'

[Chromedriver] Set chromedriver binary as: /Applications/Appium.app/Contents/Resources/node_modules/appium/node_modules/appium-android-driver/node_modules/appium-chromedriver/chromedriver/mac/chromedriver

[Chromedriver] Killing any old chromedrivers, running: pkill -15 -f "/Applications/Appium.app/Contents/Resources/node_modules/appium/node_modules/appium-android-driver/node_modules/appium-chromedriver/chromedriver/mac/chromedriver.*--port=9515"
[Chromedriver] No old chromedrivers seemed to exist
[Chromedriver] Spawning chromedriver with: /Applications/Appium.app/Contents/Resources/node_modules/appium/node_modules/appium-android-driver/node_modules/appium-chromedriver/chromedriver/mac/chromedriver --url-base=wd/hub --port=9515 --adb-port=5037

[Chromedriver] [STDOUT] Starting ChromeDriver 2.21.371459 (36d3d07f660ff2bc1bf28a75d1cdabed0983e7c4) on port 9515
Only local connections are allowed.

[JSONWP Proxy] Proxying [GET /status] to [GET http://127.0.0.1:9515/wd/hub/status] with no body

[Chromedriver] [STDERR] [warn] kq_init: detected broken kqueue; not using.: Undefined error: 0

[JSONWP Proxy] Got response with status 200: "{\"sessionId\":\"\",\"stat...

[JSONWP Proxy] Proxying [POST /session] to [POST http://127.0.0.1:9515/wd/hub/session] with body: {"desiredCapabilities":{"ch...

[HTTP] --> GET /wd/hub/status {}

[MJSONWP] Calling AppiumDriver.getStatus() with args: []

[MJSONWP] Responding to client with driver.getStatus() result: {"build":{"version":"1.5.3"...
[HTTP] <-- GET /wd/hub/status 200 23 ms - 83 

[JSONWP Proxy] Got response with status 200: {"sessionId":"b4353cddcfe84...

[debug] [Chromedriver] Changed state to 'online'

[MJSONWP] Responding to client with driver.setContext() result: null
[HTTP] <-- POST /wd/hub/session/92eb802a-778c-4ce9-8540-cc723d82e29e/context 200 61100 ms - 76 
[HTTP] --> GET /wd/hub/session/92eb802a-778c-4ce9-8540-cc723d82e29e/source {}
[MJSONWP] Driver proxy active, passing request on via HTTP proxy
[JSONWP Proxy] Proxying [GET /wd/hub/session/92eb802a-778c-4ce9-8540-cc723d82e29e/source] to [GET http://127.0.0.1:9515/wd/hub/session/b4353cddcfe8459654bee22f3b0928eb/source] with body: {}
[JSONWP Proxy] Got response with status 200: "{\"sessionId\":\"b4353cddc...
[JSONWP Proxy] Replacing sessionId b4353cddcfe8459654bee22f3b0928eb with 92eb802a-778c-4ce9-8540-cc723d82e29e
[HTTP] <-- GET /wd/hub/session/92eb802a-778c-4ce9-8540-cc723d82e29e/source 200 10 ms - 220 

[HTTP] --> GET /wd/hub/status {}

[MJSONWP] Calling AppiumDriver.getStatus() with args: []

[MJSONWP] Responding to client with driver.getStatus() result: {"build":{"version":"1.5.3"...
[HTTP] <-- GET /wd/hub/status 200 11 ms - 83 

[BaseDriver] Shutting down because we waited 60 seconds for a command

[debug] [AndroidDriver] Shutting down Android driver

[Appium] Closing session, cause was 'New Command Timeout of 60 seconds expired. Try customizing the timeout using the 'newCommandTimeout' desired capability'
[Appium] Removing session 92eb802a-778c-4ce9-8540-cc723d82e29e from our master session list
[debug] [AndroidDriver] Stopping chromedriver for context WEBVIEW_so.dian.operatordebug
[debug] [Chromedriver] Changed state to 'stopping'
[JSONWP Proxy] Proxying [DELETE /] to [DELETE http://127.0.0.1:9515/wd/hub/session/b4353cddcfe8459654bee22f3b0928eb] with no body
[JSONWP Proxy] Got response with status 200: "{\"sessionId\":\"b4353cddc...
[debug] [Chromedriver] Changed state to 'stopped'
[debug] [ADB] Getting connected devices...

[debug] [ADB] 1 device(s) connected
[debug] [ADB] Running /Users/lingfengzong/Downloads/android-sdk-macosx/platform-tools/adb with args: ["-P",5037,"-s","127.0.0.1:62001","shell","am","force-stop","so.dian.operatordebug"]

[debug] [ADB] Getting connected devices...

[debug] [ADB] 1 device(s) connected
[debug] [ADB] Running /Users/lingfengzong/Downloads/android-sdk-macosx/platform-tools/adb with args: ["-P",5037,"-s","127.0.0.1:62001","shell","am","force-stop","io.appium.unlock"]

[debug] [ADB] Pressing the HOME button

[debug] [ADB] Getting connected devices...

[debug] [ADB] 1 device(s) connected
[debug] [ADB] Running /Users/lingfengzong/Downloads/android-sdk-macosx/platform-tools/adb with args: ["-P",5037,"-s","127.0.0.1:62001","shell","input","keyevent",3]

[debug] [Logcat] Stopping logcat capture

[debug] [AndroidBootstrap] Sending command to android: {"cmd":"shutdown"}

[debug] [AndroidBootstrap] Received command result from bootstrap
[debug] [UiAutomator] Shutting down UiAutomator
[debug] [UiAutomator] Moving to state 'stopping'
[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
[debug] [AndroidBootstrap] [UIAUTO STDOUT] INSTRUMENTATION_STATUS: numtests=1
[debug] [AndroidBootstrap] [UIAUTO STDOUT] INSTRUMENTATION_STATUS: stream=.
[debug] [AndroidBootstrap] [UIAUTO STDOUT] INSTRUMENTATION_STATUS: id=UiAutomatorTestRunner
[debug] [AndroidBootstrap] [UIAUTO STDOUT] INSTRUMENTATION_STATUS: test=testRunServer
[debug] [AndroidBootstrap] [UIAUTO STDOUT] INSTRUMENTATION_STATUS: class=io.appium.android.bootstrap.Bootstrap
[debug] [AndroidBootstrap] [UIAUTO STDOUT] INSTRUMENTATION_STATUS: current=1
[debug] [AndroidBootstrap] [UIAUTO STDOUT] INSTRUMENTATION_STATUS_CODE: 0
[debug] [AndroidBootstrap] [UIAUTO STDOUT] INSTRUMENTATION_STATUS: stream=
[debug] [AndroidBootstrap] [UIAUTO STDOUT] Test results for WatcherResultPrinter=.
[debug] [AndroidBootstrap] [UIAUTO STDOUT] Time: 139.284
[debug] [AndroidBootstrap] [UIAUTO STDOUT] OK (1 test)
[debug] [AndroidBootstrap] [UIAUTO STDOUT] INSTRUMENTATION_STATUS_CODE: -1
[debug] [UiAutomator] UiAutomator shut down normally
[debug] [UiAutomator] Moving to state 'stopped'
[debug] [ADB] Attempting to kill all uiautomator processes
[debug] [ADB] Getting all processes with uiautomator
[debug] [ADB] Getting connected devices...
[debug] [ADB] 1 device(s) connected
[debug] [ADB] Running /Users/lingfengzong/Downloads/android-sdk-macosx/platform-tools/adb with args: ["-P",5037,"-s","127.0.0.1:62001","shell","ps","uiautomator"]

[ADB] No uiautomator process found to kill, continuing...
[debug] [UiAutomator] Moving to state 'stopped'

[HTTP] --> GET /wd/hub/status {}

[MJSONWP] Calling AppiumDriver.getStatus() with args: []

[MJSONWP] Responding to client with driver.getStatus() result: {"build":{"version":"1.5.3"...
[HTTP] <-- GET /wd/hub/status 200 12 ms - 83 

[HTTP] --> GET /wd/hub/status {}

[MJSONWP] Calling AppiumDriver.getStatus() with args: []

[MJSONWP] Responding to client with driver.getStatus() result: {"build":{"version":"1.5.3"...
[HTTP] <-- GET /wd/hub/status 200 61 ms - 83 


↙↙↙阅读原文可查看相关链接,并与作者交流