python代码
from appium import webdriver import time from selenium.webdriver.support.ui import WebDriverWait from selenium.webdriver.support import expected_conditions capabilities = { "platformName": "Android", "automationName": "UiAutomator2", "deviceName": "127.0.0.1:21503", "app": "C:\\Users\\hu xinyao\\Desktop\\Appium\\mukewang.apk", # "appActivity": "cn.com.open.mooc.index.splash.GuideActivity", "noReset": "true", } port = "4723" driver = webdriver.Remote('http://127.0.0.1:'+port+'/wd/hub', capabilities)日志信息
[info] [35m[Appium][39m Welcome to Appium v1.8.1 [info] [35m[Appium][39m Appium REST http interface listener started on 0.0.0.0:4723[info] [35m[HTTP][39m [37m-->[39m [37mPOST[39m [37m/wd/hub/session[39m [info] [35m[HTTP][39m [90m{"capabilities":{"firstMatch":[{}],"alwaysMatch":{"platformName":"Android","appium:automationName":"UiAutomator2","appium:deviceName":"127.0.0.1:21503","appium:app":"C:\\Users\\hu xinyao\\Desktop\\Appium\\mukewang.apk","appium:noReset":"true"}},"desiredCapabilities":{"platformName":"Android","automationName":"UiAutomator2","deviceName":"127.0.0.1:21503","app":"C:\\Users\\hu xinyao\\Desktop\\Appium\\mukewang.apk","noReset":"true"}}[39m [debug] [35m[MJSONWP][39m Calling AppiumDriver.createSession() with args: [{"platformName":"Android","automationName":"UiAutomator2","deviceName":"127.0.0.1:21503","app":"C:\\Users\\hu xinyao\\Desktop\\Appium\\mukewang.apk","noReset":"true"},null,{"firstMatch":[{}],"alwaysMatch":{"platformName":"Android","appium:automationName":"UiAutomator2","appium:deviceName":"127.0.0.1:21503","appium:app":"C:\\Users\\hu xinyao\\Desktop\\Appium\\mukewang.apk","appium:noReset":"true"}}] [debug] [35m[BaseDriver][39m Event 'newSessionRequested' logged at 1532107090387 (01:18:10 GMT+0800 (中国标准时间)) [warn] [35m[BaseDriver][39m Boolean capability passed in as string. Functionality may be compromised. [info] [35m[Appium][39m Creating new AndroidUiautomator2Driver (v1.12.0) session [info] [35m[Appium][39m Capabilities: [info] [35m[Appium][39m platformName: Android [info] [35m[Appium][39m automationName: UiAutomator2 [info] [35m[Appium][39m deviceName: 127.0.0.1:21503 [info] [35m[Appium][39m app: C:\Users\hu xinyao\Desktop\Appium\mukewang.apk [info] [35m[Appium][39m noReset: true [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... [warn] [35m[BaseDriver][39m Boolean capability passed in as string. Functionality may be compromised. [warn] [35m[BaseDriver][39m Capability 'noReset' changed from string to boolean. This may cause unexpected behavior [info] [35m[BaseDriver][39m Session created with session id: 9aca201a-acd5-4a7e-9d5b-8b5a466b885c [info] [35m[BaseDriver][39m Using local app 'C:\Users\hu xinyao\Desktop\Appium\mukewang.apk' [debug] [35m[UiAutomator2][39m Checking whether app is actually present[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 1 'build-tools' folders under 'C:\Program Files\Java\sdk' (newest first): [info] [35m[ADB][39m C:/Program Files/Java/sdk/build-tools/android-4.3 [info] [35m[ADB][39m Using adb.exe from C:\Program Files\Java\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 Using device: 127.0.0.1:21503 [debug] [35m[ADB][39m Setting device id to 127.0.0.1:21503 [debug] [35m[ADB][39m Running 'C:\Program Files\Java\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[AndroidDriver][39m Parsing package and activity from app manifest [info] [35m[ADB][39m Using the alternative activity name detection method because of: Could not find apkanalyzer.bat in C:\Program Files\Java\sdk\platform-tools\apkanalyzer.bat,C:\Program Files\Java\sdk\emulator\apkanalyzer.bat,C:\Program Files\Java\sdk\tools\apkanalyzer.bat,C:\Program Files\Java\sdk\tools\bin\apkanalyzer.bat,C:\Program Files\Java\sdk\build-tools\android-4.3\apkanalyzer.bat. Do you have the Android SDK installed at 'C:\Program Files\Java\sdk'? [info] [35m[ADB][39m Checking whether aapt is present [info] [35m[ADB][39m Using aapt.exe from C:\Program Files\Java\sdk\tools\aapt.exe [info] [35m[ADB][39m Extracting package and launch activity from manifest [info] [35m[ADB][39m Package name: 'cn.com.open.mooc' [info] [35m[ADB][39m Main activity name: 'cn.com.open.mooc.index.splash.MCSplashActivity' [debug] [35m[AndroidDriver][39m Parsed package and activity are: cn.com.open.mooc/cn.com.open.mooc.index.splash.MCSplashActivity [info] [35m[ADB][39m Getting device platform version [debug] [35m[ADB][39m Running 'C:\Program Files\Java\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 'C:\Program Files\Java\sdk\platform-tools\adb.exe -P 5037 -s 127.0.0.1\:21503 shell wm size'[debug] [35m[ADB][39m Running 'C:\Program Files\Java\sdk\platform-tools\adb.exe -P 5037 -s 127.0.0.1\:21503 shell wm density'[debug] [35m[ADB][39m Running 'C:\Program Files\Java\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.manufacturer': samsung [debug] [35m[ADB][39m Device API level: 22 [debug] [35m[ADB][39m Running 'C:\Program Files\Java\sdk\platform-tools\adb.exe -P 5037 -s 127.0.0.1\:21503 shell am force-stop io.appium.uiautomator2.server'[debug] [35m[ADB][39m Checking app cert for C:\Program Files (x86)\Appium\resources\app\node_modules\appium\node_modules\appium-uiautomator2-server\apks\appium-uiautomator2-server-v1.12.0.apk [warn] [35m[ADB][39m Cannot use apksigner tool for signature verification. Defaulting to verify.jar. Original error: Could not find apksigner.bat in C:\Program Files\Java\sdk\platform-tools\apksigner.bat,C:\Program Files\Java\sdk\emulator\apksigner.bat,C:\Program Files\Java\sdk\tools\apksigner.bat,C:\Program Files\Java\sdk\tools\bin\apksigner.bat,C:\Program Files\Java\sdk\build-tools\android-4.3\apksigner.bat. Do you have the Android SDK installed at 'C:\Program Files\Java\sdk'?[debug] [35m[ADB][39m 'C:\Program Files (x86)\Appium\resources\app\node_modules\appium\node_modules\appium-uiautomator2-server\apks\appium-uiautomator2-server-v1.12.0.apk' is not signed with debug cert. [debug] [35m[ADB][39m Signing 'C:\Program Files (x86)\Appium\resources\app\node_modules\appium\node_modules\appium-uiautomator2-server\apks\appium-uiautomator2-server-v1.12.0.apk' with default cert [warn] [35m[ADB][39m Cannot use apksigner tool for signing. Defaulting to sign.jar. Original error: Could not find apksigner.bat in C:\Program Files\Java\sdk\platform-tools\apksigner.bat,C:\Program Files\Java\sdk\emulator\apksigner.bat,C:\Program Files\Java\sdk\tools\apksigner.bat,C:\Program Files\Java\sdk\tools\bin\apksigner.bat,C:\Program Files\Java\sdk\build-tools\android-4.3\apksigner.bat. Do you have the Android SDK installed at 'C:\Program Files\Java\sdk'? [debug] [35m[ADB][39m Resigning apk.[debug] [35m[UiAutomator2][39m Deleting UiAutomator2 session [debug] [35m[UiAutomator2][39m Deleting UiAutomator2 server session [warn] [35m[UiAutomator2][39m Did not get confirmation UiAutomator2 deleteSession worked; Error was: Error: Trying to proxy a session command without session id [debug] [35m[ADB][39m Running 'C:\Program Files\Java\sdk\platform-tools\adb.exe -P 5037 -s 127.0.0.1\:21503 shell am force-stop cn.com.open.mooc'[debug] [35m[ADB][39m Removing forwarded port socket connection: 8200 [debug] [35m[ADB][39m Running 'C:\Program Files\Java\sdk\platform-tools\adb.exe -P 5037 -s 127.0.0.1\:21503 forward --remove tcp\:8200' [debug] [35m[ADB][39m Running 'C:\Program Files\Java\sdk\platform-tools\adb.exe -P 5037 -s 127.0.0.1\:21503 forward --remove tcp\:8200'[warn] [35m[UiAutomator2][39m Unable to remove port forward 'Error executing adbExec. Original error: 'Command ''C:\\Program Files\\Java\\sdk\\platform-tools\\adb.exe' -P 5037 -s 127.0.0.1\:21503 forward --remove tcp\:8200' exited with code 1'; Stderr: 'error: cannot remove listener'; Code: '1'' [debug] [35m[BaseDriver][39m Event 'newSessionStarted' logged at 1532107096223 (01:18:16 GMT+0800 (中国标准时间)) [error] [35m[W3C][39m Encountered internal error running command: Error: Could not sign with default certificate. Original error Command ''C:\\Program Files\\Java\\jdk1.8.0_161\\bin\\java.exe' -jar 'C:\\Program Files (x86)\\Appium\\resources\\app\\node_modules\\appium\\node_modules\\appium-adb\\jars\\sign.jar' 'C:\\Program Files (x86)\\Appium\\resources\\app\\node_modules\\appium\\node_modules\\appium-uiautomator2-server\\apks\\appium-uiautomator2-server-v1.12.0.apk' --override' exited with code 1 [error] [35m[W3C][39m at ADB.callee$0$0$ (C:\Program Files (x86)\Appium\resources\app\node_modules\appium\node_modules\appium-adb\lib\tools\apk-signing.js:79:13) [error] [35m[W3C][39m at tryCatch (C:\Program Files (x86)\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 (x86)\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 (x86)\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 (x86)\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 [90m5856 ms - 2278[39m [info] [35m[HTTP][39m [90m[39m