在特定页面本机应用程序上打开驱动程序

时间:2016-07-06 06:31:07

标签: android selenium c#-4.0 appium

我有一个原生应用,我想调试一个特定的页面。问题是,每次我运行我的代码(webdriver)我的应用程序是从头开始(从启动屏幕),然后我需要等待整个过程来获取此页面,以便调试它。 我正在使用Appium和c#-selenium作为Android应用。  的修改 这是我的Appium的日志:

> Launching Appium server with command: C:\Appium\node.exe lib\server\main.js --address 127.0.0.1 --port 4723 --platform-name Android --platform-version 21 --automation-name Appium --log-no-color
> info: Welcome to Appium v1.4.16 (REV ae6877eff263066b26328d457bd285c0cc62430d)
> info: Appium REST http interface listener started on 127.0.0.1:4723
> info: [debug] Non-default server args: {"address":"127.0.0.1","logNoColors":true,"platformName":"Android","platformVersion":"21","automationName":"Appium"}
> info: Console LogLevel: debug
> info: --> POST /wd/hub/session {"desiredCapabilities":{"device":"Android","deviceName":"Note 5","newCommandTimeout":"300","platformName":"Android","platformVersion":"5.0.1","unicodeKeyboard":true,"noReset":true,"appPackage":"com.lolatech.android.device","appActivity":"com.lolatech.android.device.activity.SplashActivity"}}
> info: Client User-Agent string: undefined
> info: [debug] The following desired capabilities were provided, but not recognized by appium. They will be passed on to any other services running on this server. : device
> info: [debug] Didn't get app but did get Android package, will attempt to launch it on the device
> info: [debug] Creating new appium session 952dbf43-1618-430b-92d6-9e9fc2e6f378
> info: Starting android appium
> info: [debug] Getting Java version
> info: Java version is: 1.7.0_79
> info: [debug] Checking whether adb is present
> info: [debug] Using adb from C:\Android\sdk\platform-tools\adb.exe
> warn: No app capability, can't parse package/activity
> info: [debug] Using fast reset? false
> info: [debug] Preparing device for session
> info: [debug] Not checking whether app is present since we are assuming it's already on the device
> info: Retrieving device
> info: [debug] Trying to find a connected android device
> info: [debug] Getting connected devices...
> info: [debug] executing cmd: C:\Android\sdk\platform-tools\adb.exe devices
> info: [debug] 1 device(s) connected
> info: Found device 1115fb838f713904
> info: [debug] Setting device id to 1115fb838f713904
> info: [debug] Waiting for device to be ready and to respond to shell commands (timeout = 5)
> info: [debug] executing cmd: C:\Android\sdk\platform-tools\adb.exe -s 1115fb838f713904 wait-for-device
> info: [debug] executing cmd: C:\Android\sdk\platform-tools\adb.exe -s 1115fb838f713904 shell "echo 'ready'"
> info: [debug] Starting logcat capture
> info: [debug] Getting device API level
> info: [debug] executing cmd: C:\Android\sdk\platform-tools\adb.exe -s 1115fb838f713904 shell "getprop ro.build.version.sdk"
> info: [debug] Device is at API Level 22
> info: Device API level is: 22
> info: [debug] Extracting strings for language: default
> info: [debug] Apk doesn't exist locally
> info: [debug] Could not get strings, but it looks like we had an old strings file anyway, so ignoring
> info: [debug] executing cmd: C:\Android\sdk\platform-tools\adb.exe -s 1115fb838f713904 shell "rm -rf /data/local/tmp/strings.json"
> info: [debug] Not uninstalling app since server not started with --full-reset
> info: [debug] Skipping install since we launched with a package instead of an app path
> info: [debug] Forwarding system:4724 to device:4724
> info: [debug] executing cmd: C:\Android\sdk\platform-tools\adb.exe -s 1115fb838f713904 forward tcp:4724 tcp:4724
> info: [debug] Pushing appium bootstrap to device...
> info: [debug] executing cmd: C:\Android\sdk\platform-tools\adb.exe -s 1115fb838f713904 push "C:\\Appium\\node_modules\\appium\\build\\android_bootstrap\\AppiumBootstrap.jar" /data/local/tmp/
> info: [debug] Enabling Unicode keyboard support
> info: [debug] Pushing unicode ime to device...
> info: [debug] executing cmd: C:\Android\sdk\platform-tools\adb.exe -s 1115fb838f713904 install "C:\Appium\node_modules\appium\build\unicode_ime_apk\UnicodeIME-debug.apk"
> info: [debug] executing cmd: C:\Android\sdk\platform-tools\adb.exe -s 1115fb838f713904 shell "settings get secure default_input_method"
> info: [debug] Unsetting IME 'io.appium.android.ime/.UnicodeIME'
> info: [debug] Setting IME to 'io.appium.android.ime/.UnicodeIME'
> info: [debug] executing cmd: C:\Android\sdk\platform-tools\adb.exe -s 1115fb838f713904 shell "ime enable io.appium.android.ime/.UnicodeIME"
> info: [debug] executing cmd: C:\Android\sdk\platform-tools\adb.exe -s 1115fb838f713904 shell "ime set io.appium.android.ime/.UnicodeIME"
> info: [debug] Pushing settings apk to device...
> info: [debug] executing cmd: C:\Android\sdk\platform-tools\adb.exe -s 1115fb838f713904 install "C:\Appium\node_modules\appium\build\settings_apk\settings_apk-debug.apk"
> info: [debug] Pushing unlock helper app to device...
> info: [debug] executing cmd: C:\Android\sdk\platform-tools\adb.exe -s 1115fb838f713904 install "C:\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:\Android\sdk\platform-tools\adb.exe -s 1115fb838f713904 shell "ps 'uiautomator'"
> info: [debug] No matching processes found
> info: [debug] Running bootstrap
> info: [debug] spawning: C:\Android\sdk\platform-tools\adb.exe -s 1115fb838f713904 shell uiautomator runtest AppiumBootstrap.jar -c io.appium.android.bootstrap.Bootstrap -e pkg com.lolatech.android.device -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] 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: {"status":0,"value":true}
> info: [debug] executing cmd: C:\Android\sdk\platform-tools\adb.exe -s 1115fb838f713904 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] [BOOTSTRAP] [debug] Returning result: {"status":0,"value":"\/data\/local\/tmp"}
> info: [debug] dataDir set to: /data/local/tmp
> info: [debug] Pushing command to appium work queue: ["compressedLayoutHierarchy",{"compressLayout":false}]
> 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: {"status":0,"value":false}
> info: [debug] Getting device API level
> info: [debug] executing cmd: C:\Android\sdk\platform-tools\adb.exe -s 1115fb838f713904 shell "getprop ro.build.version.sdk"
> info: [debug] Device is at API Level 22
> info: [debug] executing cmd: C:\Android\sdk\platform-tools\adb.exe -s 1115fb838f713904 shell "am start -S -a android.intent.action.MAIN -c android.intent.category.LAUNCHER -f 0x10200000 -n com.lolatech.android.device/com.lolatech.android.device.activity.SplashActivity"
> info: [debug] Waiting for pkg "com.lolatech.android.device" and activity "com.lolatech.android.device.activity.SplashActivity" to be focused
> info: [debug] Getting focused package and activity
> info: [debug] executing cmd: C:\Android\sdk\platform-tools\adb.exe -s 1115fb838f713904 shell "dumpsys window windows"
> info: [debug] executing cmd: C:\Android\sdk\platform-tools\adb.exe -s 1115fb838f713904 shell "getprop ro.build.version.release"
> info: [debug] Device is at release version 5.1.1
> info: [debug] Device launched! Ready for commands
> info: [debug] Setting command timeout to 300 secs
> info: [debug] Appium session started with sessionId 952dbf43-1618-430b-92d6-9e9fc2e6f378
> info: <-- POST /wd/hub/session 303 10760.340 ms - 74 
> info: --> GET /wd/hub/session/952dbf43-1618-430b-92d6-9e9fc2e6f378 {}
> info: [debug] Responding to client with success: {"status":0,"value":{"platform":"LINUX","browserName":"Android","platformVersion":"5.1.1","webStorageEnabled":false,"takesScreenshot":true,"javascriptEnabled":true,"databaseEnabled":false,"networkConnectionEnabled":true,"locationContextEnabled":false,"warnings":{},"desired":{"device":"Android","deviceName":"Note 5","newCommandTimeout":"300","platformName":"Android","platformVersion":"5.0.1","unicodeKeyboard":true,"noReset":true,"appPackage":"com.lolatech.android.device","appActivity":"com.lolatech.android.device.activity.SplashActivity"},"device":"Android","deviceName":"1115fb838f713904","newCommandTimeout":"300","platformName":"Android","unicodeKeyboard":true,"noReset":true,"appPackage":"com.lolatech.android.device","appActivity":"com.lolatech.android.device.activity.SplashActivity"},"sessionId":"952dbf43-1618-430b-92d6-9e9fc2e6f378"}
> info: <-- GET /wd/hub/session/952dbf43-1618-430b-92d6-9e9fc2e6f378 200 4.003 ms - 847 {"status":0,"value":{"platform":"LINUX","browserName":"Android","platformVersion":"5.1.1","webStorageEnabled":false,"takesScreenshot":true,"javascriptEnabled":true,"databaseEnabled":false,"networkConnectionEnabled":true,"locationContextEnabled":false,"warnings":{},"desired":{"device":"Android","deviceName":"Note 5","newCommandTimeout":"300","platformName":"Android","platformVersion":"5.0.1","unicodeKeyboard":true,"noReset":true,"appPackage":"com.lolatech.android.device","appActivity":"com.lolatech.android.device.activity.SplashActivity"},"device":"Android","deviceName":"1115fb838f713904","newCommandTimeout":"300","platformName":"Android","unicodeKeyboard":true,"noReset":true,"appPackage":"com.lolatech.android.device","appActivity":"com.lolatech.android.device.activity.SplashActivity"},"sessionId":"952dbf43-1618-430b-92d6-9e9fc2e6f378"}
> info: --> DELETE /wd/hub/session/952dbf43-1618-430b-92d6-9e9fc2e6f378 {}
> info: Shutting down appium session
> info: [debug] Pressing the HOME button
> info: [debug] executing cmd: C:\Android\sdk\platform-tools\adb.exe -s 1115fb838f713904 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: {"status":0,"value":"OK, shutting down"}
> 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] [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: 3.077
> info: [debug] [UIAUTOMATOR STDOUT] OK (1 test)
> info: [debug] [UIAUTOMATOR STDOUT] INSTRUMENTATION_STATUS_CODE: -1
> info: [debug] Sent shutdown command, waiting for UiAutomator to stop...
> 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":"952dbf43-1618-430b-92d6-9e9fc2e6f378"}
> info: <-- DELETE /wd/hub/session/952dbf43-1618-430b-92d6-9e9fc2e6f378 200 806.391 ms - 76 {"status":0,"value":null,"sessionId":"952dbf43-1618-430b-92d6-9e9fc2e6f378"}

1 个答案:

答案 0 :(得分:0)

您需要在功能中将noReset设置为true,以便在每次执行自动化脚本时停止清理数据。

第二部分启动特定屏幕/页面。假设页面不需要任何数据或条件这样的登录,您可以通过startActivity()方法启动活动。但是,您需要对源代码进行修改。您需要将特定活动设置为已导出。如清单文件中所示。

<activity
    android:name=".SomeActivity"
    ....
    android:exported="true" />