同遇到,一开始是用 Python 遇到,可以点击,send_keys 会报参数错误,然后换 JAVA 遇到跟你一样的问题,我准备降级试下。。
debug 看到 findElement 是有,传到 click 后好像就变成 1 了,不太擅长 debug 这些看不懂的代码。。
我把 selenium 降级成 3.4.2 运行没有问题。
双赢的提示信息
#3 楼 @liu492018451 启动这个运行你的代码就可以了- -
#19 楼 @xiayuxiamo 现在的新版本已经不需要做这个事情了吧?如果你是 Node 安装的,启动的时候在 appium 的命令后面加就可以了,如果是 appiumforwindows 那么就不需要加这个参数了。不过我已经好久好久没有用过这个参数了,不用也没有遇到什么大问题。。这个参数跟你用什么代码写的脚本没有关系,是 appium 的服务启动参数
#13 楼 @umbrella1978 我今晚有事在加班~回你可能晚点,不好意思啊~
#13 楼 @umbrella1978
对了,貌似代码里面设置是否使用 selendroid 的优先级没有在 exe 里面设置的高。。我刚才忘记设置回 exe 的 selendroid 为 appium,然后一直报错- -
#13 楼 @umbrella1978
那就是用 4.4 的设备咯~
设置了,但乱码了。。没有解锁手机
> Starting Node Server
> info: Welcome to Appium v1.2.0 (REV e53f49c706a25242e66d36685c268b599cc18da5)
> ERROR: debug: Non-default server args: {"address":"127.0.0.1","logNoColors":true,"platformName":"Android","platformVersion":"19","automationName":"Appium"}
> info: Appium REST http interface listener started on 127.0.0.1:4723
> info: LogLevel: debug
> info: --> POST /wd/hub/session {"desiredCapabilities":{"deviceName":"61625b81","app":"F:\\Download\\test.apk","appPackage":"com.test.android.app","appActivity":"ui.main.MainActivity","platformVersion":"4.4","platformName":"Android"}}
> ERROR: debug: Appium request initiated at /wd/hub/session
> ERROR: debug: Request received with params: {"desiredCapabilities":{"deviceName":"61625b81","app":"F:\\Download\\test.apk","appPackage":"com.test.android.app","appActivity":"ui.main.MainActivity","platformVersion":"4.4","platformName":"Android"}}
> info: Starting android appium
> ERROR: debug: Using local app from desired caps: F:\Download\test.apk
> ERROR: debug: Creating new appium session ba2e0a0b-5419-4438-a876-5262cdbb07c6
> info: Retrieving device
> ERROR: debug: Using fast reset? true
> ERROR: debug: Preparing device for session
> ERROR: debug: Checking whether app is actually present
> ERROR: debug: Checking whether adb is present
> ERROR: debug: Using adb from E:\android-sdk-windows\platform-tools\adb.exe
> ERROR: debug: Trying to find a connected android device
> ERROR: debug: Getting connected devices...
> ERROR: debug: executing: "E:\android-sdk-windows\platform-tools\adb.exe" devices
> ERROR: debug: 1 device(s) connected
> info: Found device 61625b81
> ERROR: debug: Setting device id to 61625b81
> ERROR: debug: Waiting for device to be ready and to respond to shell commands (timeout = 5)
> ERROR: debug: executing: "E:\android-sdk-windows\platform-tools\adb.exe" -s 61625b81 wait-for-device
> ERROR: debug: executing: "E:\android-sdk-windows\platform-tools\adb.exe" -s 61625b81 shell "echo 'ready'"
> ERROR: debug: Starting logcat capture
> ERROR: debug: Getting device API level
> ERROR: debug: executing: "E:\android-sdk-windows\platform-tools\adb.exe" -s 61625b81 shell "getprop ro.build.version.sdk"
> ERROR: debug: Device is at API Level 19
> info: Device API level is: 19
> ERROR: debug: executing: "E:\android-sdk-windows\platform-tools\adb.exe" -s 61625b81 shell "getprop persist.sys.language"
> ERROR: debug: Current device language: en
> ERROR: debug: java -jar "E:\Appium\node_modules\appium\node_modules\appium-adb\jars\strings_from_apk.jar" "F:\Download\test.apk" "C:\Windows\Temp\com.test.android.app" en
> ERROR: debug: No strings.xml for language 'en', getting default strings.xml
> ERROR: debug: java -jar "E:\Appium\node_modules\appium\node_modules\appium-adb\jars\strings_from_apk.jar" "F:\Download\test.apk" "C:\Windows\Temp\com.test.android.app"
> warn: Error getting strings.xml from apk
> ERROR: debug: 'java' 锟斤拷锟斤拷锟节诧拷锟斤拷锟解部锟斤拷锟筋,也锟斤拷锟角匡拷锟斤拷锟叫的筹拷锟斤拷
> ERROR: 锟斤拷锟斤拷锟斤拷锟斤拷锟侥硷拷锟斤拷
> ERROR:
> ERROR: debug: executing: "E:\android-sdk-windows\platform-tools\adb.exe" -s 61625b81 shell "echo '{}' > /data/local/tmp/strings.json"
> ERROR: debug: Checking whether aapt is present
> ERROR: debug: Using aapt from E:\android-sdk-windows\build-tools\20.0.0\aapt.exe
> ERROR: debug: processFromManifest: "E:\android-sdk-windows\build-tools\20.0.0\aapt.exe" dump xmltree "F:\Download\test.apk" AndroidManifest.xml
> ERROR: debug: Set app process to: com.test.android.app
> ERROR: debug: Not uninstalling app since server not started with --full-reset
> ERROR: debug: Checking app cert for F:\Download\test.apk: java -jar "E:\Appium\node_modules\appium\node_modules\appium-adb\jars\verify.jar" "F:\Download\test.apk"
> ERROR: debug: App not signed with debug cert.
> ERROR: debug: Resigning apk with: java -jar "E:\Appium\node_modules\appium\node_modules\appium-adb\jars\sign.jar" "F:\Download\test.apk" --override
> ERROR: debug: Stopping logcat capture
> ERROR: debug: Logcat terminated with code null, signal SIGTERM
> ERROR: debug: Sent shutdown command, waiting for UiAutomator to stop...
> warn: UiAutomator did not shut down fast enough, calling it gone
> ERROR: debug: Cleaning up android objects
> ERROR: debug: Cleaning up appium session
> ERROR: error: Failed to start an Appium session, err was: Error: Command failed: 'java' 锟斤拷锟斤拷锟节诧拷锟斤拷锟解部锟斤拷锟筋,也锟斤拷锟角匡拷锟斤拷锟叫的筹拷锟斤拷
> ERROR: 锟斤拷锟斤拷锟斤拷锟斤拷锟侥硷拷锟斤拷
> ERROR:
> ERROR: debug: Error: Command failed: 'java' 锟斤拷锟斤拷锟节诧拷锟斤拷锟解部锟斤拷锟筋,也锟斤拷锟角匡拷锟斤拷锟叫的筹拷锟斤拷
> ERROR: 锟斤拷锟斤拷锟斤拷锟斤拷锟侥硷拷锟斤拷
> ERROR:
> ERROR: at ChildProcess.exithandler (child_process.js:637:15)
> ERROR: at ChildProcess.EventEmitter.emit (events.js:98:17)
> ERROR: at maybeClose (child_process.js:743:16)
> ERROR: at Process.ChildProcess._handle.onexit (child_process.js:810:5)
> ERROR: debug: Responding to client with error: {"status":33,"value":{"message":"A new session could not be created. (Original error: Command failed: 'java' 锟斤拷锟斤拷锟节诧拷锟斤拷锟解部锟斤拷锟筋,也锟斤拷锟角匡拷锟斤拷锟叫的筹拷锟斤拷\r\n锟斤拷锟斤拷锟斤拷锟斤拷锟侥硷拷锟斤拷\r\n)","killed":false,"code":1,"signal":null,"origValue":"Command failed: 'java' 锟斤拷锟斤拷锟节诧拷锟斤拷锟解部锟斤拷锟筋,也锟斤拷锟角匡拷锟斤拷锟叫的筹拷锟斤拷\r\n锟斤拷锟斤拷锟斤拷锟斤拷锟侥硷拷锟斤拷\r\n"},"sessionId":null}
#8 楼 @umbrella1978
刚刚才看就删除了- - 我已经找了,没有这个代码
SDK 是最新的 23.0.2(我不太确认你说的 SDK 环境变量是哪个 SDK- -感觉应该是 Android 吧)
我现在要在 4.1.2 上运行,所以 exe 里面我就选了 16 的,刚刚选回 19 还是一样报错了~
#6 楼 @umbrella1978
但是我是启动设备上已安装的程序,如果是这样就没有办法了,但是试下后还是不可以- - 感觉问题越来越奇怪了。。
> info: Welcome to Appium v1.2.0 (REV e53f49c706a25242e66d36685c268b599cc18da5)
> ERROR: debug: Non-default server args: {"address":"127.0.0.1","logNoColors":true,"platformName":"Android","platformVersion":"16","automationName":"Selendroid"}
> info: Appium REST http interface listener started on 127.0.0.1:4723
> info: LogLevel: debug
> info: --> POST /wd/hub/session {"desiredCapabilities":{"platformVersion":"4.1","app":"F:\\Download\\test.apk","platformName":"Android","appActivity":"ui.main.MainActivity","deviceName":"61625b81","appPackage":"com.test.android.app","automationName":"Selendroid"}}
> ERROR: debug: Appium request initiated at /wd/hub/session
> ERROR: debug: Request received with params: {"desiredCapabilities":{"platformVersion":"4.1","app":"F:\\Download\\test.apk","platformName":"Android","appActivity":"ui.main.MainActivity","deviceName":"61625b81","appPackage":"com.test.android.app","automationName":"Selendroid"}}
> ERROR: debug: Using local app from desired caps: F:\Download\test.apk
> ERROR: debug: Creating new appium session 46274a47-3a53-4fc8-abb0-bd825c826268
> ERROR: debug: Starting selendroid server
> ERROR: debug: Checking whether selendroid is built yet
> ERROR: debug: Selendroid server exists!
> ERROR: debug: Preparing device for session
> ERROR: debug: Checking whether app is actually present
> ERROR: debug: Checking whether adb is present
> info: Retrieving device
> ERROR: debug: Using adb from E:\android-sdk-windows\platform-tools\adb.exe
> ERROR: debug: Trying to find a connected android device
> ERROR: debug: Getting connected devices...
> ERROR: debug: executing: "E:\android-sdk-windows\platform-tools\adb.exe" devices
> info: Found device 148904d2
> ERROR: debug: 1 device(s) connected
> ERROR: debug: Setting device id to 148904d2
> ERROR: debug: Waiting for device to be ready and to respond to shell commands (timeout = 5)
> ERROR: debug: executing: "E:\android-sdk-windows\platform-tools\adb.exe" -s 148904d2 wait-for-device
> ERROR: debug: executing: "E:\android-sdk-windows\platform-tools\adb.exe" -s 148904d2 shell "echo 'ready'"
> ERROR: debug: Starting logcat capture
> ERROR: debug: Rebuilt selendroid apk does not exist, uninstalling any instances of it on device to make way for new one
> ERROR: debug: Uninstalling com.test.android.app.selendroid
> ERROR: debug: executing: "E:\android-sdk-windows\platform-tools\adb.exe" -s 148904d2 shell "am force-stop com.test.android.app.selendroid"
> ERROR: debug: executing: "E:\android-sdk-windows\platform-tools\adb.exe" -s 148904d2 uninstall com.test.android.app.selendroid
> ERROR: debug: App was not uninstalled, maybe it wasn't on device?
> ERROR: debug: Rebuilt selendroid server does not exist, inserting modified manifest
> ERROR: debug: Inserting selendroid manifest
> ERROR: debug: Checking whether aapt is present
> info: <-- POST /wd/hub/session 500 2166.004 ms - 220
> ERROR: debug: Using aapt from E:\android-sdk-windows\build-tools\20.0.0\aapt.exe
> ERROR: debug: Compiling manifest C:\Windows\Temp\com.test.android.app\AndroidManifest.xml
> ERROR: debug: Cleaning up appium session
> ERROR: error: Failed to start an Appium session, err was: Error: Required platform doesn't exist (API level >= 17)
> ERROR: debug: Error: Required platform doesn't exist (API level >= 17)
> ERROR: at ADB.compileManifest (E:\Appium\node_modules\appium\node_modules\appium-adb\lib\adb.js:290:15)
> ERROR: at null.<anonymous> (E:\Appium\node_modules\appium\lib\devices\android\selendroid.js:390:16)
> ERROR: at E:\Appium\node_modules\appium\node_modules\async\lib\async.js:610:21
> ERROR: at E:\Appium\node_modules\appium\node_modules\async\lib\async.js:249:17
> ERROR: at iterate (E:\Appium\node_modules\appium\node_modules\async\lib\async.js:149:13)
> ERROR: at E:\Appium\node_modules\appium\node_modules\async\lib\async.js:160:25
> ERROR: at E:\Appium\node_modules\appium\node_modules\async\lib\async.js:251:21
> ERROR: at E:\Appium\node_modules\appium\node_modules\async\lib\async.js:615:34
> ERROR: at ADB.checkSdkBinaryPresent (E:\Appium\node_modules\appium\node_modules\appium-adb\lib\adb.js:113:5)
> ERROR: at null.<anonymous> (E:\Appium\node_modules\appium\lib\devices\android\selendroid.js:388:30)
> ERROR: debug: Responding to client with error: {"status":33,"value":{"message":"A new session could not be created. (Original error: Required platform doesn't exist (API level >= 17))","origValue":"Required platform doesn't exist (API level >= 17)"},"sessionId":null}
#3 楼 @umbrella1978
在 exe 里面换了 4.1 的还是不可以,设备是 4.1.2 报的错基本是一样的,已删除 node 上的 appium。
> info: --> POST /wd/hub/session {"desiredCapabilities":{"platformName":"Android","automationName":"Selendroid","platformVersion":"4.1","appPackage":"com.test.android.app","appActivity":"ui.main.MainActivity","deviceName":"61625b81"}}
> ERROR: debug: Appium request initiated at /wd/hub/session
> ERROR: debug: Request received with params: {"desiredCapabilities":{"platformName":"Android","automationName":"Selendroid","platformVersion":"4.1","appPackage":"com.test.android.app","appActivity":"ui.main.MainActivity","deviceName":"61625b81"}}
> info: Retrieving device
> ERROR: debug: Didn't get app but did get Android package, will attempt to launch it on the device
> ERROR: debug: Creating new appium session eb8eee56-a665-4fad-b3fa-51e8a0bc2972
> ERROR: debug: Starting selendroid server
> ERROR: debug: Checking whether selendroid is built yet
> ERROR: debug: Selendroid server exists!
> ERROR: debug: Preparing device for session
> ERROR: debug: Not checking whether app is present since we are assuming it's already on the device
> ERROR: debug: Checking whether adb is present
> ERROR: debug: Using adb from E:\android-sdk-windows\platform-tools\adb.exe
> ERROR: debug: Trying to find a connected android device
> ERROR: debug: Getting connected devices...
> ERROR: debug: executing: "E:\android-sdk-windows\platform-tools\adb.exe" devices
> ERROR: debug: 1 device(s) connected
> info: Found device 148904d2
> ERROR: debug: Setting device id to 148904d2
> ERROR: debug: Waiting for device to be ready and to respond to shell commands (timeout = 5)
> ERROR: debug: executing: "E:\android-sdk-windows\platform-tools\adb.exe" -s 148904d2 wait-for-device
> ERROR: debug: executing: "E:\android-sdk-windows\platform-tools\adb.exe" -s 148904d2 shell "echo 'ready'"
> ERROR: debug: Starting logcat capture
> warn: No app capability, can't parse package/activity
> ERROR: debug: Rebuilt selendroid apk does not exist, uninstalling any instances of it on device to make way for new one
> ERROR: debug: Uninstalling com.test.android.app.selendroid
> ERROR: debug: executing: "E:\android-sdk-windows\platform-tools\adb.exe" -s 148904d2 shell "am force-stop com.test.android.app.selendroid"
> ERROR: debug: executing: "E:\android-sdk-windows\platform-tools\adb.exe" -s 148904d2 uninstall com.test.android.app.selendroid
> ERROR: debug: App was not uninstalled, maybe it wasn't on device?
> ERROR: debug: Rebuilt selendroid server does not exist, inserting modified manifest
> ERROR: debug: Inserting selendroid manifest
> info: <-- POST /wd/hub/session 500 2153.804 ms - 220
> ERROR: debug: Checking whether aapt is present
> ERROR: debug: Using aapt from E:\android-sdk-windows\build-tools\20.0.0\aapt.exe
> ERROR: debug: Compiling manifest C:\Windows\Temp\com.test.android.app\AndroidManifest.xml
> ERROR: debug: Cleaning up appium session
> ERROR: error: Failed to start an Appium session, err was: Error: Required platform doesn't exist (API level >= 17)
> ERROR: debug: Error: Required platform doesn't exist (API level >= 17)
> ERROR: at ADB.compileManifest (E:\Appium\node_modules\appium\node_modules\appium-adb\lib\adb.js:290:15)
> ERROR: at null.<anonymous> (E:\Appium\node_modules\appium\lib\devices\android\selendroid.js:390:16)
> ERROR: at E:\Appium\node_modules\appium\node_modules\async\lib\async.js:610:21
> ERROR: at E:\Appium\node_modules\appium\node_modules\async\lib\async.js:249:17
> ERROR: at iterate (E:\Appium\node_modules\appium\node_modules\async\lib\async.js:149:13)
> ERROR: at E:\Appium\node_modules\appium\node_modules\async\lib\async.js:160:25
> ERROR: at E:\Appium\node_modules\appium\node_modules\async\lib\async.js:251:21
> ERROR: at E:\Appium\node_modules\appium\node_modules\async\lib\async.js:615:34
> ERROR: at ADB.checkSdkBinaryPresent (E:\Appium\node_modules\appium\node_modules\appium-adb\lib\adb.js:113:5)
> ERROR: at null.<anonymous> (E:\Appium\node_modules\appium\lib\devices\android\selendroid.js:388:30)
> ERROR: debug: Responding to client with error: {"status":33,"value":{"message":"A new session could not be created. (Original error: Required platform doesn't exist (API level >= 17))","origValue":"Required platform doesn't exist (API level >= 17)"},"sessionId":null}
刚刚看日志时看到是不是无法自动启动应用是因为 1.2 自身的 BUG- -
日志里面有解析报错
> warn: No app capability, can't parse package/activity
#3 楼 @umbrella1978
倒是想起一个可能,我一开始是装了 nodejs 上的 appium 的,后来才转用 appiumfor win 的;晚点我卸载掉 node 的版本看看还有没有这个问题,其实我以前用 0.X 版本的时候就已经没有办法使用低版本的系统了,只是当时学习也没有怎么管这个问题,毕竟小问题;
刚才我看了下我 exe 里面的设置的确是有默认的值- - 是 4.2 的。。我一会儿试试
锁屏的我试过解锁后才使用也一样无法启动,而且解锁的功能目前在我这里看起来是挺正常的~每次都可以正常解锁手机,只是解锁后就不知道去启动应用了- -
还有一个因素不知道是不是跟我用的系统有关系,我用的是 CM 的,晚点也找其它人的设备试下~
有问题我再找你~谢谢你~
#1 楼 @umbrella1978
设备 ID 的问题:我试过 ID 不过也可以正常启动所以我就没有每次都换 ID 了;
问题 2:启动后就指定了 19 的 API,这个问题我也不知道怎么回事。。所以我才提问的。。不知道是不是 1.2 的问题还是我的代码有问题- - 或者是一些我目前还不知道的因素导致的。
#11 楼 @zhouxiaoyagirl serveniruby 说得对,你的 Activity 名字写错了吧?要是 Mainifest.xml 里面写的那个 Activity 的名字哈~
#9 楼 @zhouxiaoyagirl 嗯,我能重现你的问题了,你先把 APK 安装到手机上,然后把 desired_caps 的 app 干掉, appium 启动加参数 --no-reset,试下吧
#7 楼 @zhouxiaoyagirl r u sure? 你试下卸载掉重新安装一次?我倒是没有遇到过,你以前可以正常使用的么?重装后如果不行把你的代码贴下,让大家看看
#5 楼 @zhouxiaoyagirl 没有,直接不用这个功能就好了- -