问答 [请教坛里同志和前辈] 按钮"allow"似乎没有被按

speng · March 24, 2017 · Last by speng replied at September 15, 2017 · 1447 hits

比较初级的问题,但是折腾了好久,就是找不到原因。
希望有经验的前辈能帮忙看看有没有问题,如果有,出在哪里?
多谢多谢,不胜感激!

appium 1.4.16.1
windows10-64 bits
python2.7
phone huawei honor6-4.4.2

希望 appium 能够实现按钮点击 “allow”

我的脚本代码:
sleep(6)
self.driver.find_element_by_xpath("//android.widget.Button[@text='Allow']").click

我的 appium 日志:

info: --> POST /wd/hub/session {"requiredCapabilities":{},"desiredCapabilities":{"platformVersion":"4.4.2","deviceName":"022SSE146M005259","platformName":"Android","appActivity":"com.jabra.sport.core.ui.SplashActivity","appPackage":"com.jabra.sport"}}
info: Client User-Agent string: Python-urllib/2.7
info: [debug] Using local app from command line: C:\MyDownloads\JabraSportLife-3_1_2-SNAPSHOT-3010200-debug.apk
info: [debug] Creating new appium session d05bd16a-4be4-4377-9f7f-be5c0734106f
info: Starting android appium
info: [debug] Getting Java version
info: Java version is: 1.8.0_121
info: [debug] Checking whether adb is present
info: [debug] Using adb from C:\AndroidSDK\platform-tools\adb.exe
info: [debug] Using fast reset? true
info: [debug] Preparing device for session
info: [debug] Checking whether app is actually present
info: Retrieving device
info: [debug] Trying to find a connected android device
info: [debug] Getting connected devices...
info: [debug] executing cmd: C:\AndroidSDK\platform-tools\adb.exe devices
info: [debug] 1 device(s) connected
info: Found device 022SSE146M005259
info: [debug] Setting device id to 022SSE146M005259
info: [debug] Waiting for device to be ready and to respond to shell commands (timeout = 5)
info: [debug] executing cmd: C:\AndroidSDK\platform-tools\adb.exe -s 022SSE146M005259 wait-for-device
info: [debug] executing cmd: C:\AndroidSDK\platform-tools\adb.exe -s 022SSE146M005259 shell "echo 'ready'"
info: [debug] Starting logcat capture
info: [debug] Getting device API level
info: [debug] executing cmd: C:\AndroidSDK\platform-tools\adb.exe -s 022SSE146M005259 shell "getprop ro.build.version.sdk"
info: [debug] Device is at API Level 19
info: Device API level is: 19
info: [debug] Extracting strings for language: default
info: [debug] executing cmd: C:\AndroidSDK\platform-tools\adb.exe -s 022SSE146M005259 shell "getprop persist.sys.language"
info: [debug] Current device persist.sys.language: en
info: [debug] java -jar "C:\Program Files (x86)\Appium\node_modules\appium\node_modules\appium-adb\jars\appium_apk_tools.jar" "stringsFromApk" "C:\MyDownloads\JabraSportLife-3_1_2-SNAPSHOT-3010200-debug.apk" "C:\Users\speng\AppData\Local\Temp\com.jabra.sport" en
info: [debug] No strings.xml for language 'en', getting default strings.xml
info: [debug] java -jar "C:\Program Files (x86)\Appium\node_modules\appium\node_modules\appium-adb\jars\appium_apk_tools.jar" "stringsFromApk" "C:\MyDownloads\JabraSportLife-3_1_2-SNAPSHOT-3010200-debug.apk" "C:\Users\speng\AppData\Local\Temp\com.jabra.sport"
info: [debug] Reading strings from converted strings.json
info: [debug] Setting language to default
info: [debug] executing cmd: C:\AndroidSDK\platform-tools\adb.exe -s 022SSE146M005259 push "C:\Users\speng\AppData\Local\Temp\com.jabra.sport\strings.json" /data/local/tmp
info: [debug] Checking whether aapt is present
info: [debug] Using aapt from C:\AndroidSDK\build-tools\25.0.1\aapt.exe
info: [debug] Retrieving process from manifest.
info: [debug] executing cmd: C:\AndroidSDK\build-tools\25.0.1\aapt.exe dump xmltree C:\MyDownloads\JabraSportLife-3_1_2-SNAPSHOT-3010200-debug.apk AndroidManifest.xml
info: [debug] Set app process to: com.jabra.sport
info: [debug] Not uninstalling app since server not started with --full-reset
info: [debug] Checking app cert for C:\MyDownloads\JabraSportLife-3_1_2-SNAPSHOT-3010200-debug.apk.
info: [debug] executing cmd: java -jar "C:\Program Files (x86)\Appium\node_modules\appium\node_modules\appium-adb\jars\verify.jar" C:\MyDownloads\JabraSportLife-3_1_2-SNAPSHOT-3010200-debug.apk
info: [debug] App already signed.
info: [debug] Zip-aligning C:\MyDownloads\JabraSportLife-3_1_2-SNAPSHOT-3010200-debug.apk
info: [debug] Checking whether zipalign is present
info: [debug] Using zipalign from C:\AndroidSDK\build-tools\25.0.1\zipalign.exe
info: [debug] Zip-aligning apk.
info: [debug] executing cmd: C:\AndroidSDK\build-tools\25.0.1\zipalign.exe -f 4 C:\MyDownloads\JabraSportLife-3_1_2-SNAPSHOT-3010200-debug.apk C:\Users\speng\AppData\Local\Temp\117224-12628-1byysyk\appium.tmp
info: [debug] MD5 for app is 269a8b7d81c774571d30184c9af7dc92
info: [debug] executing cmd: C:\AndroidSDK\platform-tools\adb.exe -s 022SSE146M005259 shell "ls /data/local/tmp/269a8b7d81c774571d30184c9af7dc92.apk"
info: [debug] Getting install status for com.jabra.sport
info: [debug] Getting device API level
info: [debug] executing cmd: C:\AndroidSDK\platform-tools\adb.exe -s 022SSE146M005259 shell "getprop ro.build.version.sdk"
info: [debug] Device is at API Level 19
info: [debug] executing cmd: C:\AndroidSDK\platform-tools\adb.exe -s 022SSE146M005259 shell "pm list packages -3 com.jabra.sport"
info: [debug] App is installed
info: App is already installed, resetting app
info: [debug] Running fast reset (stop and clear)
info: [debug] executing cmd: C:\AndroidSDK\platform-tools\adb.exe -s 022SSE146M005259 shell "am force-stop com.jabra.sport"
info: [debug] executing cmd: C:\AndroidSDK\platform-tools\adb.exe -s 022SSE146M005259 shell "pm clear com.jabra.sport"
info: [debug] Forwarding system:4724 to device:4724
info: [debug] executing cmd: C:\AndroidSDK\platform-tools\adb.exe -s 022SSE146M005259 forward tcp:4724 tcp:4724
info: [debug] Pushing appium bootstrap to device...
info: [debug] executing cmd: C:\AndroidSDK\platform-tools\adb.exe -s 022SSE146M005259 push "C:\Program Files (x86)\Appium\node_modules\appium\build\android_bootstrap\AppiumBootstrap.jar" /data/local/tmp/
info: [debug] Pushing settings apk to device...
info: [debug] executing cmd: C:\AndroidSDK\platform-tools\adb.exe -s 022SSE146M005259 install "C:\Program Files (x86)\Appium\node_modules\appium\build\settings_apk\settings_apk-debug.apk"
info: [debug] Pushing unlock helper app to device...
info: [debug] executing cmd: C:\AndroidSDK\platform-tools\adb.exe -s 022SSE146M005259 install "C:\Program Files (x86)\Appium\node_modules\appium\build\unlock_apk\unlock_apk-debug.apk"
info: Starting App
info: [debug] Attempting to kill all 'uiautomator' processes
info: [debug] Getting all processes with 'uiautomator'
info: [debug] executing cmd: C:\AndroidSDK\platform-tools\adb.exe -s 022SSE146M005259 shell "ps 'uiautomator'"
info: [debug] No matching processes found
info: [debug] Running bootstrap
info: [debug] spawning: C:\AndroidSDK\platform-tools\adb.exe -s 022SSE146M005259 shell uiautomator runtest AppiumBootstrap.jar -c io.appium.android.bootstrap.Bootstrap -e pkg com.jabra.sport -e disableAndroidWatchers false
info: [debug] [UIAUTOMATOR STDOUT] INSTRUMENTATION_STATUS: numtests=1
info: [debug] [UIAUTOMATOR STDOUT] INSTRUMENTATION_STATUS: stream=
info: [debug] [UIAUTOMATOR STDOUT] io.appium.android.bootstrap.Bootstrap:
info: [debug] [UIAUTOMATOR STDOUT] INSTRUMENTATION_STATUS: id=UiAutomatorTestRunner
info: [debug] [UIAUTOMATOR STDOUT] INSTRUMENTATION_STATUS: test=testRunServer
info: [debug] [UIAUTOMATOR STDOUT] INSTRUMENTATION_STATUS: class=io.appium.android.bootstrap.Bootstrap
info: [debug] [UIAUTOMATOR STDOUT] INSTRUMENTATION_STATUS: current=1
info: [debug] [UIAUTOMATOR STDOUT] INSTRUMENTATION_STATUS_CODE: 1
info: [debug] [BOOTSTRAP] [debug] Socket opened on port 4724
info: [debug] [BOOTSTRAP] [debug] Appium Socket Server Ready
info: [debug] [BOOTSTRAP] [debug] Loading json...
info: [debug] Waking up device if it's not alive
info: [debug] Pushing command to appium work queue: ["wake",{}]
info: [debug] [BOOTSTRAP] [debug] json loading complete.
info: [debug] [BOOTSTRAP] [debug] Registered crash watchers.
info: [debug] [BOOTSTRAP] [debug] Client connected
info: [debug] [BOOTSTRAP] [debug] Got data from client: {"cmd":"action","action":"wake","params":{}}
info: [debug] [BOOTSTRAP] [debug] Got command of type ACTION
info: [debug] [BOOTSTRAP] [debug] Got command action: wake
info: [debug] [BOOTSTRAP] [debug] Returning result: {"value":true,"status":0}
info: [debug] executing cmd: C:\AndroidSDK\platform-tools\adb.exe -s 022SSE146M005259 shell "dumpsys window"
info: [debug] Screen already unlocked, continuing.
info: [debug] Pushing command to appium work queue: ["getDataDir",{}]
info: [debug] [BOOTSTRAP] [debug] Got data from client: {"cmd":"action","action":"getDataDir","params":{}}
info: [debug] [BOOTSTRAP] [debug] Got command of type ACTION
info: [debug] [BOOTSTRAP] [debug] Got command action: getDataDir
info: [debug] dataDir set to: /data/local/tmp
info: [debug] Pushing command to appium work queue: ["compressedLayoutHierarchy",{"compressLayout":false}]
info: [debug] [BOOTSTRAP] [debug] Returning result: {"value":"\/data\/local\/tmp","status":0}
info: [debug] [BOOTSTRAP] [debug] Got data from client: {"cmd":"action","action":"compressedLayoutHierarchy","params":{"compressLayout":false}}
info: [debug] [BOOTSTRAP] [debug] Got command of type ACTION
info: [debug] [BOOTSTRAP] [debug] Got command action: compressedLayoutHierarchy
info: [debug] [BOOTSTRAP] [debug] Returning result: {"value":false,"status":0}
info: [debug] Getting device API level
info: [debug] executing cmd: C:\AndroidSDK\platform-tools\adb.exe -s 022SSE146M005259 shell "getprop ro.build.version.sdk"
info: [debug] Device is at API Level 19
info: [debug] executing cmd: C:\AndroidSDK\platform-tools\adb.exe -s 022SSE146M005259 shell "am start -S -a android.intent.action.MAIN -c android.intent.category.LAUNCHER -f 0x10200000 -n com.jabra.sport/com.jabra.sport.core.ui.SplashActivity"
info: [debug] Waiting for pkg "com.jabra.sport" and activity "com.jabra.sport.core.ui.SplashActivity" to be focused
info: [debug] Getting focused package and activity
info: [debug] executing cmd: C:\AndroidSDK\platform-tools\adb.exe -s 022SSE146M005259 shell "dumpsys window windows"
info: [debug] executing cmd: C:\AndroidSDK\platform-tools\adb.exe -s 022SSE146M005259 shell "getprop ro.build.version.release"
info: [debug] Device is at release version 4.4.2
info: [debug] Device launched! Ready for commands
info: [debug] Setting command timeout to the default of 60 secs
info: [debug] Appium session started with sessionId d05bd16a-4be4-4377-9f7f-be5c0734106f
info: <-- POST /wd/hub/session 303 14306.346 ms - 74
info: --> GET /wd/hub/session/d05bd16a-4be4-4377-9f7f-be5c0734106f {}
info: [debug] Responding to client with success: {"status":0,"value":{"platform":"LINUX","browserName":"Android","platformVersion":"4.4.2","webStorageEnabled":false,"takesScreenshot":true,"javascriptEnabled":true,"databaseEnabled":false,"networkConnectionEnabled":true,"locationContextEnabled":false,"warnings":{},"desired":{"platformVersion":"4.4.2","deviceName":"022SSE146M005259","platformName":"Android","appActivity":"com.jabra.sport.core.ui.SplashActivity","appPackage":"com.jabra.sport"},"deviceName":"022SSE146M005259","platformName":"Android","appActivity":"com.jabra.sport.core.ui.SplashActivity","appPackage":"com.jabra.sport"},"sessionId":"d05bd16a-4be4-4377-9f7f-be5c0734106f"}
info: <-- GET /wd/hub/session/d05bd16a-4be4-4377-9f7f-be5c0734106f 200 2.344 ms - 641 {"status":0,"value":{"platform":"LINUX","browserName":"Android","platformVersion":"4.4.2","webStorageEnabled":false,"takesScreenshot":true,"javascriptEnabled":true,"databaseEnabled":false,"networkConnectionEnabled":true,"locationContextEnabled":false,"warnings":{},"desired":{"platformVersion":"4.4.2","deviceName":"022SSE146M005259","platformName":"Android","appActivity":"com.jabra.sport.core.ui.SplashActivity","appPackage":"com.jabra.sport"},"deviceName":"022SSE146M005259","platformName":"Android","appActivity":"com.jabra.sport.core.ui.SplashActivity","appPackage":"com.jabra.sport"},"sessionId":"d05bd16a-4be4-4377-9f7f-be5c0734106f"}
info: --> POST /wd/hub/session/d05bd16a-4be4-4377-9f7f-be5c0734106f/element {"using":"xpath","sessionId":"d05bd16a-4be4-4377-9f7f-be5c0734106f","value":"//android.widget.Button[@text='Allow']"}
info: [debug] Waiting up to 0ms for condition
info: [debug] Pushing command to appium work queue: ["find",{"strategy":"xpath","selector":"//android.widget.Button[@text='Allow']","context":"","multiple":false}]
info: [debug] [BOOTSTRAP] [debug] Got data from client: {"cmd":"action","action":"find","params":{"strategy":"xpath","selector":"//android.widget.Button[@text='Allow']","context":"","multiple":false}}
info: [debug] [BOOTSTRAP] [debug] Got command of type ACTION
info: [debug] [BOOTSTRAP] [debug] Got command action: find
info: [debug] [BOOTSTRAP] [debug] Finding //android.widget.Button[@text='Allow'] using XPATH with the contextId: multiple: false
info: [debug] [BOOTSTRAP] [debug] Using: UiSelector[CLASS=android.widget.Button, INSTANCE=1]
info: [debug] [BOOTSTRAP] [debug] Returning result: {"value":{"ELEMENT":"1"},"status":0}
info: [debug] Responding to client with success: {"status":0,"value":{"ELEMENT":"1"},"sessionId":"d05bd16a-4be4-4377-9f7f-be5c0734106f"}
info: <-- POST /wd/hub/session/d05bd16a-4be4-4377-9f7f-be5c0734106f/element 200 247.680 ms - 87 {"status":0,"value":{"ELEMENT":"1"},"sessionId":"d05bd16a-4be4-4377-9f7f-be5c0734106f"}
info: --> DELETE /wd/hub/session/d05bd16a-4be4-4377-9f7f-be5c0734106f {}
info: Shutting down appium session
info: [debug] Pressing the HOME button
info: [debug] executing cmd: C:\AndroidSDK\platform-tools\adb.exe -s 022SSE146M005259 shell "input keyevent 3"
info: [debug] Stopping logcat capture
info: [debug] Logcat terminated with code null, signal SIGTERM
info: [debug] [BOOTSTRAP] [debug] Got data from client: {"cmd":"shutdown"}
info: [debug] [BOOTSTRAP] [debug] Got command of type SHUTDOWN
info: [debug] [BOOTSTRAP] [debug] Returning result: {"value":"OK, shutting down","status":0}
info: [debug] [BOOTSTRAP] [debug] Closed client connection
info: [debug] [UIAUTOMATOR STDOUT] INSTRUMENTATION_STATUS: numtests=1
info: [debug] [UIAUTOMATOR STDOUT] INSTRUMENTATION_STATUS: stream=.
info: [debug] [UIAUTOMATOR STDOUT] INSTRUMENTATION_STATUS: id=UiAutomatorTestRunner
info: [debug] [UIAUTOMATOR STDOUT] INSTRUMENTATION_STATUS: test=testRunServer
info: [debug] [UIAUTOMATOR STDOUT] INSTRUMENTATION_STATUS: class=io.appium.android.bootstrap.Bootstrap
info: [debug] Sent shutdown command, waiting for UiAutomator to stop...
info: [debug] [UIAUTOMATOR STDOUT] INSTRUMENTATION_STATUS: current=1
info: [debug] [UIAUTOMATOR STDOUT] INSTRUMENTATION_STATUS_CODE: 0
info: [debug] [UIAUTOMATOR STDOUT] INSTRUMENTATION_STATUS: stream=
info: [debug] [UIAUTOMATOR STDOUT] Test results for WatcherResultPrinter=.
info: [debug] [UIAUTOMATOR STDOUT] Time: 8.791
info: [debug] [UIAUTOMATOR STDOUT] OK (1 test)
info: [debug] [UIAUTOMATOR STDOUT] INSTRUMENTATION_STATUS_CODE: -1
info: [debug] UiAutomator shut down normally
info: [debug] Cleaning up android objects
info: [debug] Cleaning up appium session
info: [debug] Responding to client with success: {"status":0,"value":null,"sessionId":"d05bd16a-4be4-4377-9f7f-be5c0734106f"}
info: <-- DELETE /wd/hub/session/d05bd16a-4be4-4377-9f7f-be5c0734106f 200 705.449 ms - 76 {"status":0,"value":null,"sessionId":"d05bd16a-4be4-4377-9f7f-be5c0734106f"}

共收到 2 条回复 时间 点赞

日志里好像没有 click 的动作:

info: [debug] [BOOTSTRAP] [debug] Using: UiSelector[CLASS=android.widget.Button, INSTANCE=1]
info: [debug] [BOOTSTRAP] [debug] Returning result: {"value":{"ELEMENT":"1"},"status":0}
info: [debug] Responding to client with success: {"status":0,"value":{"ELEMENT":"1"},"sessionId":"d05bd16a-4be4-4377-9f7f-be5c0734106f"}
info: <-- POST /wd/hub/session/d05bd16a-4be4-4377-9f7f-be5c0734106f/element 200 247.680 ms - 87 {"status":0,"value":{"ELEMENT":"1"},"sessionId":"d05bd16a-4be4-4377-9f7f-be5c0734106f"}
info: --> DELETE /wd/hub/session/d05bd16a-4be4-4377-9f7f-be5c0734106f {}

恒温 回复

谢谢大神,我的低级失误,抱歉让你费心了,已经解决了!!!

恒温 关闭了讨论 15 Sep 10:34
需要 Sign In 后方可回复, 如果你还没有账号请点击这里 Sign Up