raise exception_class(message, screen, stacktrace)
selenium.common.exceptions.WebDriverException: Message: An unknown server-side error occurred while processing the comma
nd. Original error: Cannot start the 'com.wondershare.drfone' application. Original error: Error executing adbExec. Orig
inal error: 'Command 'D\:\\Andriod_SDK\\platform-tools\\adb.exe -P 5037 -s 127.0.0.1\:21503 shell am start -W -n com.won
dershare.drfone/com.wondershare.drfone.ui.activity.WelcomeActivity -S' timed out after 20000ms'; Stderr: ''; Code: 'null'
1.测试设备:逍遥模拟器 Android 5.1.1 /Chrome 66.0
2.PC系统环境: Win7 32bit /Chrome 66.0
from appium import webdriver
from selenium.webdriver.support.ui import WebDriverWait
desired_caps={}
desired_caps['platformName']='Android'
desired_caps['platformVersion']='5.1.1'
desired_caps['deviceName']='127.0.0.1:21503'
desired_caps['app']='C:\pyln\dr.fone3.2.0.apk'
desired_caps['appPackage']='com.wondershare.drfone'
desired_caps['appActivity']='com.wondershare.drfone.ui.activity.WelcomeActivity'
driver = webdriver.Remote('http://localhost:4723/wd/hub',desired_caps)
driver.implicitly_wait(5)
print('click BackupBtn')
driver.find_element_by_id('com.wondershare.drfone:id/btnBackup').click()
WebDriverWait(driver,8).until(lambda x:x.find_element_by_id('com.wondershare.drfone:id/btnRecoverData'))
print('click NextBtn')
driver.find_element_by_id('com.wondershare.drfone:id/btnRecoverData').click()
WebDriverWait(driver,8).until(lambda x:x.find_element_by_class_name('android.webkit.WebView'))
contexts=driver.contexts
print(contexts)
[info] [35m[Appium][39m Welcome to Appium v1.8.1[info] [35m[HTTP][39m [37m-->[39m [37mPOST[39m [37m/wd/hub/session[39m
[info] [35m[HTTP][39m [90m{"capabilities":{"firstMatch":[{}],"alwaysMatch":{"platformName":"Android","appium:platformVersion":"5.1.1","appium:deviceName":"127.0.0.1:21503","appium:app":"C:\\pyln\\dr.fone3.2.0.apk","appium:appPackage":"com.wondershare.drfone","appium:appActivity":"com.wondershare.drfone.ui.activity.WelcomeActivity"}},"desiredCapabilities":{"platformName":"Android","platformVersion":"5.1.1","deviceName":"127.0.0.1:21503","app":"C:\\pyln\\dr.fone3.2.0.apk","appPackage":"com.wondershare.drfone","appActivity":"com.wondershare.drfone.ui.activity.WelcomeActivity"}}[39m
[debug] [35m[MJSONWP][39m Calling AppiumDriver.createSession() with args: [{"platformName":"Android","platformVersion":"5.1.1","deviceName":"127.0.0.1:21503","app":"C:\\pyln\\dr.fone3.2.0.apk","appPackage":"com.wondershare.drfone","appActivity":"com.wondershare.drfone.ui.activity.WelcomeActivity"},null,{"firstMatch":[{}],"alwaysMatch":{"platformName":"Android","appium:platformVersion":"5.1.1","appium:deviceName":"127.0.0.1:21503","appium:app":"C:\\pyln\\dr.fone3.2.0.apk","appium:appPackage":"com.wondershare.drfone","appium:appActivity":"com.wondershare.drfone.ui.activity.WelcomeActivity"}}]
[debug] [35m[BaseDriver][39m Event 'newSessionRequested' logged at 1537943514254 (14:31:54 GMT+0800 (中国标准时间))
[info] [35m[Appium][39m Creating new AndroidDriver (v2.7.0) session
[info] [35m[Appium][39m Capabilities:
[info] [35m[Appium][39m platformName: Android
[info] [35m[Appium][39m platformVersion: 5.1.1
[info] [35m[Appium][39m deviceName: 127.0.0.1:21503
[info] [35m[Appium][39m app: C:\pyln\dr.fone3.2.0.apk
[info] [35m[Appium][39m appPackage: com.wondershare.drfone
[info] [35m[Appium][39m appActivity: com.wondershare.drfone.ui.activity.WelcomeActivity
[debug] [35m[BaseDriver][39m W3C capabilities {"alwaysMatch":{"platformNa... and MJSONWP desired capabilities [object Object] were provided
[debug] [35m[BaseDriver][39m Creating session with W3C capabilities: {"alwaysMatch":{"platformNa...
[info] [35m[BaseDriver][39m Session created with session id: 2955de37-5ae9-4a6c-b31f-32b768bddc58
[debug] [35m[AndroidDriver][39m Getting Java version[info] [35m[AndroidDriver][39m Java version is: 1.8.0_161
[info] [35m[ADB][39m Checking whether adb is present
[info] [35m[ADB][39m Found 26 'build-tools' folders under 'D:\Andriod_SDK' (newest first):
[info] [35m[ADB][39m D:/Andriod_SDK/build-tools/28.0.2
[info] [35m[ADB][39m D:/Andriod_SDK/build-tools/28.0.1
[info] [35m[ADB][39m D:/Andriod_SDK/build-tools/28.0.0
[info] [35m[ADB][39m D:/Andriod_SDK/build-tools/27.0.3
[info] [35m[ADB][39m D:/Andriod_SDK/build-tools/27.0.2
[info] [35m[ADB][39m D:/Andriod_SDK/build-tools/27.0.1
[info] [35m[ADB][39m D:/Andriod_SDK/build-tools/27.0.0
[info] [35m[ADB][39m D:/Andriod_SDK/build-tools/26.0.3
[info] [35m[ADB][39m D:/Andriod_SDK/build-tools/26.0.2
[info] [35m[ADB][39m D:/Andriod_SDK/build-tools/26.0.1
[info] [35m[ADB][39m D:/Andriod_SDK/build-tools/26.0.0
[info] [35m[ADB][39m D:/Andriod_SDK/build-tools/25.0.3
[info] [35m[ADB][39m D:/Andriod_SDK/build-tools/25.0.2
[info] [35m[ADB][39m D:/Andriod_SDK/build-tools/25.0.1
[info] [35m[ADB][39m D:/Andriod_SDK/build-tools/25.0.0
[info] [35m[ADB][39m D:/Andriod_SDK/build-tools/24.0.3
[info] [35m[ADB][39m D:/Andriod_SDK/build-tools/24.0.2
[info] [35m[ADB][39m D:/Andriod_SDK/build-tools/24.0.1
[info] [35m[ADB][39m D:/Andriod_SDK/build-tools/24.0.0
[info] [35m[ADB][39m D:/Andriod_SDK/build-tools/23.0.3
[info] [35m[ADB][39m D:/Andriod_SDK/build-tools/23.0.2
[info] [35m[ADB][39m D:/Andriod_SDK/build-tools/23.0.1
[info] [35m[ADB][39m D:/Andriod_SDK/build-tools/22.0.1
[info] [35m[ADB][39m D:/Andriod_SDK/build-tools/21.1.2
[info] [35m[ADB][39m D:/Andriod_SDK/build-tools/20.0.0
[info] [35m[ADB][39m D:/Andriod_SDK/build-tools/19.1.0
[info] [35m[ADB][39m Using adb.exe from D:\Andriod_SDK\platform-tools\adb.exe
[info] [35m[AndroidDriver][39m Retrieving device list
[debug] [35m[ADB][39m Trying to find a connected android device
[debug] [35m[ADB][39m Getting connected devices...[debug] [35m[ADB][39m 1 device(s) connected
[info] [35m[AndroidDriver][39m Looking for a device with Android '5.1.1'
[debug] [35m[ADB][39m Setting device id to 127.0.0.1:21503
[info] [35m[ADB][39m Getting device platform version
[debug] [35m[ADB][39m Running 'D:\Andriod_SDK\platform-tools\adb.exe -P 5037 -s 127.0.0.1\:21503 shell getprop ro.build.version.release'[debug] [35m[ADB][39m Current device property 'ro.build.version.release': 5.1.1
[info] [35m[AndroidDriver][39m Using device: 127.0.0.1:21503
[debug] [35m[ADB][39m Setting device id to 127.0.0.1:21503
[info] [35m[BaseDriver][39m Using local app 'C:\pyln\dr.fone3.2.0.apk'
[debug] [35m[AndroidDriver][39m Checking whether app is actually present
[info] [35m[AndroidDriver][39m Starting Android session
[debug] [35m[ADB][39m Running 'D:\Andriod_SDK\platform-tools\adb.exe -P 5037 -s 127.0.0.1\:21503 wait-for-device'
[debug] [35m[ADB][39m Running 'D:\Andriod_SDK\platform-tools\adb.exe -P 5037 -s 127.0.0.1\:21503 shell echo ping'[debug] [35m[AndroidDriver][39m Pushing settings apk to device...
[debug] [35m[ADB][39m Getting install status for io.appium.settings
[debug] [35m[ADB][39m Running 'D:\Andriod_SDK\platform-tools\adb.exe -P 5037 -s 127.0.0.1\:21503 shell pm list packages io.appium.settings'[debug] [35m[ADB][39m App is not installed
[debug] [35m[ADB][39m App 'C:\Program Files\Appium\resources\app\node_modules\appium\node_modules\io.appium.settings\app\build\outputs\apk\settings_apk-debug.apk' not installed. Installing
[debug] [35m[ADB][39m Running 'D:\Andriod_SDK\platform-tools\adb.exe -P 5037 -s 127.0.0.1\:21503 shell getprop ro.build.version.sdk'[debug] [35m[ADB][39m Current device property 'ro.build.version.sdk': 22
[debug] [35m[ADB][39m Device API level: 22
[debug] [35m[ADB][39m Skipping granting permissions for 'C:\Program Files\Appium\resources\app\node_modules\appium\node_modules\io.appium.settings\app\build\outputs\apk\settings_apk-debug.apk', since the current API level 22 does not support applications permissions customization
[debug] [35m[ADB][39m Running 'D:\Andriod_SDK\platform-tools\adb.exe -P 5037 -s 127.0.0.1\:21503 install 'C:\\Program Files\\Appium\\resources\\app\\node_modules\\appium\\node_modules\\io.appium.settings\\app\\build\\outputs\\apk\\settings_apk-debug.apk''[debug] [35m[ADB][39m Install command stdout: [100%] /data/local/tmp/settings_apk-debug.apk
[debug] [35m[ADB][39m C:\Program Files\Appium\resources\app\node_modules\appium\node_modules\io.appium.settings\app\build\outputs\apk\settings_apk-debug.apk: 1 file pushed. 0.1 MB/s (45149 bytes in 0.414s)
[debug] [35m[ADB][39m pkg: /data/local/tmp/settings_apk-debug.apk
[debug] [35m[ADB][39m Success
[debug] [35m[ADB][39m Running 'D:\Andriod_SDK\platform-tools\adb.exe -P 5037 -s 127.0.0.1\:21503 shell ps'[debug] [35m[ADB][39m Device API level: 22
[debug] [35m[ADB][39m Running 'D:\Andriod_SDK\platform-tools\adb.exe -P 5037 -s 127.0.0.1\:21503 shell am start -W -n io.appium.settings/.Settings -a android.intent.action.MAIN -c android.intent.category.LAUNCHER -f 0x10200000'[debug] [35m[ADB][39m Device API level: 22
[debug] [35m[ADB][39m Running 'D:\Andriod_SDK\platform-tools\adb.exe -P 5037 -s 127.0.0.1\:21503 shell settings put secure mock_location 1'[warn] [35m[AndroidDriver][39m setDeviceLanguageCountry requires language or country.
[warn] [35m[AndroidDriver][39m Got language: 'undefined' and country: 'undefined'
[debug] [35m[Logcat][39m Starting logcat capture[debug] [35m[AndroidDriver][39m Pushing unlock helper app to device...
[debug] [35m[ADB][39m Getting install status for io.appium.unlock
[debug] [35m[ADB][39m Running 'D:\Andriod_SDK\platform-tools\adb.exe -P 5037 -s 127.0.0.1\:21503 shell pm list packages io.appium.unlock'[debug] [35m[ADB][39m App is not installed
[debug] [35m[ADB][39m App 'C:\Program Files\Appium\resources\app\node_modules\appium\node_modules\appium-unlock\bin\unlock_apk-debug.apk' not installed. Installing
[debug] [35m[ADB][39m Device API level: 22
[debug] [35m[ADB][39m Skipping granting permissions for 'C:\Program Files\Appium\resources\app\node_modules\appium\node_modules\appium-unlock\bin\unlock_apk-debug.apk', since the current API level 22 does not support applications permissions customization
[debug] [35m[ADB][39m Running 'D:\Andriod_SDK\platform-tools\adb.exe -P 5037 -s 127.0.0.1\:21503 install 'C:\\Program Files\\Appium\\resources\\app\\node_modules\\appium\\node_modules\\appium-unlock\\bin\\unlock_apk-debug.apk''[debug] [35m[ADB][39m Install command stdout: [100%] /data/local/tmp/unlock_apk-debug.apk
[debug] [35m[ADB][39m C:\Program Files\Appium\resources\app\node_modules\appium\node_modules\appium-unlock\bin\unlock_apk-debug.apk: 1 file pushed. 0.1 MB/s (34611 bytes in 0.293s)
[debug] [35m[ADB][39m pkg: /data/local/tmp/unlock_apk-debug.apk
[debug] [35m[ADB][39m Success
[info] [35m[ADB][39m Getting device platform version
[debug] [35m[ADB][39m Running 'D:\Andriod_SDK\platform-tools\adb.exe -P 5037 -s 127.0.0.1\:21503 shell getprop ro.build.version.release'[debug] [35m[ADB][39m Current device property 'ro.build.version.release': 5.1.1
[debug] [35m[ADB][39m Running 'D:\Andriod_SDK\platform-tools\adb.exe -P 5037 -s 127.0.0.1\:21503 shell wm size'[debug] [35m[ADB][39m Running 'D:\Andriod_SDK\platform-tools\adb.exe -P 5037 -s 127.0.0.1\:21503 shell getprop ro.product.model'[debug] [35m[ADB][39m Current device property 'ro.product.model': SM-G9350
[debug] [35m[ADB][39m Running 'D:\Andriod_SDK\platform-tools\adb.exe -P 5037 -s 127.0.0.1\:21503 shell getprop ro.product.manufacturer'[debug] [35m[ADB][39m Current device property 'ro.product.manufacturer': samsung
[debug] [35m[ADB][39m Getting install status for com.wondershare.drfone
[debug] [35m[ADB][39m Running 'D:\Andriod_SDK\platform-tools\adb.exe -P 5037 -s 127.0.0.1\:21503 shell pm list packages com.wondershare.drfone'[debug] [35m[ADB][39m App is installed
[debug] [35m[ADB][39m Getting install status for com.wondershare.drfone
[debug] [35m[ADB][39m Running 'D:\Andriod_SDK\platform-tools\adb.exe -P 5037 -s 127.0.0.1\:21503 shell pm list packages com.wondershare.drfone'[debug] [35m[ADB][39m App is installed
[debug] [35m[ADB][39m Getting package info for 'com.wondershare.drfone'
[debug] [35m[ADB][39m Running 'D:\Andriod_SDK\platform-tools\adb.exe -P 5037 -s 127.0.0.1\:21503 shell dumpsys package com.wondershare.drfone'[info] [35m[ADB][39m Checking whether aapt is present
[info] [35m[ADB][39m Using aapt.exe from D:\Andriod_SDK\build-tools\28.0.2\aapt.exe[debug] [35m[ADB][39m The installed 'com.wondershare.drfone' package does not require upgrade ('3.2.0' >= '3.2.0')
[info] [35m[AndroidDriver][39m Performing fast reset on 'com.wondershare.drfone'
[debug] [35m[ADB][39m Getting install status for com.wondershare.drfone
[debug] [35m[ADB][39m Running 'D:\Andriod_SDK\platform-tools\adb.exe -P 5037 -s 127.0.0.1\:21503 shell pm list packages com.wondershare.drfone'[debug] [35m[ADB][39m App is installed
[debug] [35m[ADB][39m Running 'D:\Andriod_SDK\platform-tools\adb.exe -P 5037 -s 127.0.0.1\:21503 shell am force-stop com.wondershare.drfone'[debug] [35m[ADB][39m Running 'D:\Andriod_SDK\platform-tools\adb.exe -P 5037 -s 127.0.0.1\:21503 shell pm clear com.wondershare.drfone'[debug] [35m[AndroidDriver][39m Performed fast reset on the installed 'com.wondershare.drfone' application (stop and clear)
[debug] [35m[ADB][39m Running 'D:\Andriod_SDK\platform-tools\adb.exe -P 5037 -s 127.0.0.1\:21503 shell rm -rf /data/local/tmp/strings.json'[debug] [35m[AndroidDriver][39m Extracting strings from apk
[debug] [35m[AndroidDriver][39m C:\pyln\dr.fone3.2.0.apk
[debug] [35m[AndroidDriver][39m undefined
[debug] [35m[AndroidDriver][39m C:\Users\ADMINI~1\AppData\Local\Temp\com.wondershare.drfone
[debug] [35m[ADB][39m Extracting strings for language: default[info] [35m[ADB][39m Successfully extracted 418 strings from 'C:\pyln\dr.fone3.2.0.apk' resources for '(default)' configuration[debug] [35m[ADB][39m Running 'D:\Andriod_SDK\platform-tools\adb.exe -P 5037 -s 127.0.0.1\:21503 push C\:\\Users\\ADMINI~1\\AppData\\Local\\Temp\\com.wondershare.drfone\\strings.json /data/local/tmp'[debug] [35m[AndroidBootstrap][39m Watching for bootstrap disconnect
[debug] [35m[ADB][39m Forwarding system: 4724 to device: 4724
[debug] [35m[ADB][39m Running 'D:\Andriod_SDK\platform-tools\adb.exe -P 5037 -s 127.0.0.1\:21503 forward tcp\:4724 tcp\:4724'
[debug] [35m[UiAutomator][39m Starting UiAutomator
[debug] [35m[UiAutomator][39m Moving to state 'starting'
[debug] [35m[UiAutomator][39m Parsing uiautomator jar
[debug] [35m[UiAutomator][39m Found jar name: 'AppiumBootstrap.jar'
[debug] [35m[ADB][39m Running 'D:\Andriod_SDK\platform-tools\adb.exe -P 5037 -s 127.0.0.1\:21503 push 'C:\\Program Files\\Appium\\resources\\app\\node_modules\\appium\\node_modules\\appium-android-bootstrap\\bootstrap\\bin\\AppiumBootstrap.jar' /data/local/tmp/'[debug] [35m[ADB][39m Attempting to kill all uiautomator processes
[debug] [35m[ADB][39m Getting all processes with uiautomator
[debug] [35m[ADB][39m Running 'D:\Andriod_SDK\platform-tools\adb.exe -P 5037 -s 127.0.0.1\:21503 shell ps'[info] [35m[ADB][39m No uiautomator process found to kill, continuing...
[debug] [35m[UiAutomator][39m Starting UIAutomator
[debug] [35m[ADB][39m Creating ADB subprocess with args: ["-P",5037,"-s","127.0.0.1:21503","shell","uiautomator","runtest","AppiumBootstrap.jar","-c","io.appium.android.bootstrap.Bootstrap","-e","pkg","com.wondershare.drfone","-e","disableAndroidWatchers",false,"-e","acceptSslCerts",false][debug] [35m[UiAutomator][39m Moving to state 'online'
[info] [35m[AndroidBootstrap][39m Android bootstrap socket is now connected
[debug] [35m[ADB][39m Running 'D:\Andriod_SDK\platform-tools\adb.exe -P 5037 -s 127.0.0.1\:21503 shell dumpsys window'
[debug] [35m[AndroidBootstrap][39m [BOOTSTRAP LOG] [debug] Loading json...
[debug] [35m[AndroidBootstrap][39m [BOOTSTRAP LOG] [debug] json loading complete.
[debug] [35m[AndroidBootstrap][39m [BOOTSTRAP LOG] [debug] Registered crash watchers.[debug] [35m[AndroidBootstrap][39m [BOOTSTRAP LOG] [debug] Client connected[info] [35m[AndroidDriver][39m Screen already unlocked, doing nothing
[debug] [35m[ADB][39m Device API level: 22
[debug] [35m[ADB][39m Running 'D:\Andriod_SDK\platform-tools\adb.exe -P 5037 -s 127.0.0.1\:21503 shell am start -W -n com.wondershare.drfone/com.wondershare.drfone.ui.activity.WelcomeActivity -S'[debug] [35m[ADB][39m Running 'D:\Andriod_SDK\platform-tools\adb.exe -P 5037 -s 127.0.0.1\:21503 shell am start -W -n com.wondershare.drfone/com.wondershare.drfone.ui.activity.WelcomeActivity -S'[debug] [35m[AndroidDriver][39m Shutting down Android driver
[debug] [35m[ADB][39m Running 'D:\Andriod_SDK\platform-tools\adb.exe -P 5037 -s 127.0.0.1\:21503 shell am force-stop com.wondershare.drfone'[debug] [35m[ADB][39m Pressing the HOME button
[debug] [35m[ADB][39m Running 'D:\Andriod_SDK\platform-tools\adb.exe -P 5037 -s 127.0.0.1\:21503 shell input keyevent 3'[debug] [35m[AndroidBootstrap][39m Sending command to android: {"cmd":"shutdown"}[debug] [35m[AndroidBootstrap][39m [BOOTSTRAP LOG] [debug] Got data from client: {"cmd":"shutdown"}
[debug] [35m[AndroidBootstrap][39m [BOOTSTRAP LOG] [debug] Got command of type SHUTDOWN
[debug] [35m[AndroidBootstrap][39m [BOOTSTRAP LOG] [debug] Returning result: {"status":0,"value":"OK, shutting down"}
[debug] [35m[AndroidBootstrap][39m Received command result from bootstrap
[debug] [35m[UiAutomator][39m Shutting down UiAutomator
[debug] [35m[UiAutomator][39m Moving to state 'stopping'
[debug] [35m[UiAutomator][39m UiAutomator shut down normally
[debug] [35m[UiAutomator][39m Moving to state 'stopped'
[debug] [35m[ADB][39m Attempting to kill all uiautomator processes
[debug] [35m[ADB][39m Getting all processes with uiautomator
[debug] [35m[ADB][39m Running 'D:\Andriod_SDK\platform-tools\adb.exe -P 5037 -s 127.0.0.1\:21503 shell ps'[info] [35m[ADB][39m No uiautomator process found to kill, continuing...
[debug] [35m[UiAutomator][39m Moving to state 'stopped'
[debug] [35m[Logcat][39m Stopping logcat capture[debug] [35m[AndroidDriver][39m Not cleaning generated files. Add `clearSystemFiles` capability if wanted.
[debug] [35m[BaseDriver][39m Event 'newSessionStarted' logged at 1537943630645 (14:33:50 GMT+0800 (中国标准时间))
[error] [35m[W3C][39m Encountered internal error running command: Error: Cannot start the 'com.wondershare.drfone' application. Original error: Error executing adbExec. Original error: 'Command 'D\:\\Andriod_SDK\\platform-tools\\adb.exe -P 5037 -s 127.0.0.1\:21503 shell am start -W -n com.wondershare.drfone/com.wondershare.drfone.ui.activity.WelcomeActivity -S' timed out after 20000ms'; Stderr: ''; Code: 'null'
[error] [35m[W3C][39m at ADB.callee$0$0$ (C:\Program Files\Appium\resources\app\node_modules\appium\node_modules\appium-adb\lib\tools\apk-utils.js:125:11)
[error] [35m[W3C][39m at tryCatch (C:\Program Files\Appium\resources\app\node_modules\appium\node_modules\babel-runtime\regenerator\runtime.js:67:40)
[error] [35m[W3C][39m at GeneratorFunctionPrototype.invoke [as _invoke] (C:\Program Files\Appium\resources\app\node_modules\appium\node_modules\babel-runtime\regenerator\runtime.js:315:22)
[error] [35m[W3C][39m at GeneratorFunctionPrototype.prototype.(anonymous function) [as throw] (C:\Program Files\Appium\resources\app\node_modules\appium\node_modules\babel-runtime\regenerator\runtime.js:100:21)
[error] [35m[W3C][39m at GeneratorFunctionPrototype.invoke (C:\Program Files\Appium\resources\app\node_modules\appium\node_modules\babel-runtime\regenerator\runtime.js:136:37)
[error] [35m[W3C][39m at <anonymous>
[info] [35m[HTTP][39m [37m<-- POST /wd/hub/session [39m[31m500[39m [90m116610 ms - 1982[39m
[info] [35m[HTTP][39m [90m[39m
Cannot start the 'com.wondershare.drfone' application
应用都没有跑起来