公司的产品想要对 api17 以下的机型做到自动化的覆盖,查阅了相关资料。看到 selendroid 可以支持 api17 以下的测试,并且 appium 里也集成了 selendroid。
DesiredCapabilities capabilities = new DesiredCapabilities();
capabilities.setCapability("automationName", "selendroid");
//capabilities.setCapability(MobileCapabilityType.AUTOMATION_NAME, "Selendroid");
// 设置运行设备
**capabilities.setCapability("device", "Selendroid");
capabilities.setCapability("deviceName", " ");// 3230df5662738061//192.168.238.101:5555
// android18 04157df4947a1609 69T7N15B20005938
// 设置平台版本
capabilities.setCapability("platformVersion", "4.1.1");
// 设置平台的系统
capabilities.setCapability("platformName", "android");
// 设置测试包的名称
capabilities.setCapability("app-package", "com.rytong.emp.test");
// 设置udid
// capabilities.setCapability("udid", "69T7N15B20005938");
// capabilities.setCapability("udid", "192.168.56.101:5555");
// 设置测试包的入口
capabilities.setCapability("app-activity", "com.rytong.emp.test.config.ConfigActivity");
// 设置command 最大等待时间
capabilities.setCapability("newCommandTimeout", 60000);
// 设置运行的APP的路径
appPath = projectPath + "/APP/selendroid-test-app-0.17.0.apk";
capabilities.setCapability("app", appPath);
wd = new AndroidDriver(new URL("http://127.0.0.1:4723/wd/hub"), capabilities);
@Test
public void OptDownLoadJsonP0() throws InterruptedException {
WebElement
webElement = wd.findElement(By.xpath("//android.widget.Button[@text='EN Button']"));
}
info: Welcome to Appium v1.4.13 (REV c75d8adcb66a75818a542fe1891a34260c21f76a)
info: Appium REST http interface listener started on 0.0.0.0:4723
info: Console LogLevel: debug
info: --> POST /wd/hub/session {"desiredCapabilities":{"app":"/Users/shuai/Documents/workspace/AutoAppium/APP/selendroid-test-app-0.17.0.apk","newCommandTimeout":60000,"platformVersion":"4.1.1","automationName":"selendroid","app-package":"io.selendroid.androiddriver","app-activity":"io.selendroid.androiddriver.WebViewActivity","platformName":"Android","device":"Selendroid","deviceName":" "}}
info: Client User-Agent string: Apache-HttpClient/4.4.1 (Java/1.8.0_40)
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. : app-package, app-activity, device
info: [debug] No appActivity desired capability or server param. Parsing from apk.
info: [debug] No appPackage desired capability or server param. Parsing from apk.
info: [debug] Using local app from desired caps: /Users/shuai/Documents/workspace/AutoAppium/APP/selendroid-test-app-0.17.0.apk
info: [debug] Creating new appium session f82c8eca-404e-444c-9735-034d89f7f73e
info: [debug] Starting selendroid server
info: [debug] Getting Java version
info: Java version is: 1.8.0_40
info: [debug] Checking whether adb is present
info: [debug] Using adb from /usr/local/opt/android-sdk/platform-tools/adb
info: [debug] Checking whether selendroid is built yet
info: [debug] Selendroid server exists!
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: /usr/local/opt/android-sdk/platform-tools/adb devices
info: [debug] 1 device(s) connected
info: Found device 192.168.58.101:5555
info: [debug] Setting device id to 192.168.58.101:5555
info: [debug] Waiting for device to be ready and to respond to shell commands (timeout = 5)
info: [debug] executing cmd: /usr/local/opt/android-sdk/platform-tools/adb -s 192.168.58.101:5555 wait-for-device
info: [debug] executing cmd: /usr/local/opt/android-sdk/platform-tools/adb -s 192.168.58.101:5555 shell "echo 'ready'"
info: [debug] Starting logcat capture
info: [debug] Checking whether aapt is present
info: [debug] Using aapt from /usr/local/opt/android-sdk/build-tools/23.0.3/aapt
info: [debug] Checking if has internet permission from manifest.
info: [debug] executing cmd: /usr/local/opt/android-sdk/build-tools/23.0.3/aapt dump badging /Users/shuai/Documents/workspace/AutoAppium/APP/selendroid-test-app-0.17.0.apk
info: [debug] Parsing package and activity from app manifest
info: [debug] Checking whether aapt is present
info: [debug] Using aapt from /usr/local/opt/android-sdk/build-tools/23.0.3/aapt
info: [debug] Extracting package and launch activity from manifest.
info: [debug] executing cmd: /usr/local/opt/android-sdk/build-tools/23.0.3/aapt dump badging /Users/shuai/Documents/workspace/AutoAppium/APP/selendroid-test-app-0.17.0.apk
info: [debug] badging package: io.selendroid.testapp
info: [debug] badging act: io.selendroid.testapp.HomeScreenActivity
info: [debug] Parsed package and activity are: io.selendroid.testapp/io.selendroid.testapp.HomeScreenActivity
info: [debug] Rebuilt selendroid server already exists, no need to rebuild it with a new manifest
info: [debug] Checking signed status of /tmp/selendroid.io.selendroid.testapp.apk
info: [debug] Checking app cert for /tmp/selendroid.io.selendroid.testapp.apk.
info: [debug] executing cmd: java -jar /Applications/Appium.app/Contents/Resources/node_modules/appium/submodules/appium-adb/jars/verify.jar /tmp/selendroid.io.selendroid.testapp.apk
info: [debug] Checking signed status of /Users/shuai/Documents/workspace/AutoAppium/APP/selendroid-test-app-0.17.0.apk
info: [debug] Checking app cert for /Users/shuai/Documents/workspace/AutoAppium/APP/selendroid-test-app-0.17.0.apk.
info: [debug] executing cmd: java -jar /Applications/Appium.app/Contents/Resources/node_modules/appium/submodules/appium-adb/jars/verify.jar /Users/shuai/Documents/workspace/AutoAppium/APP/selendroid-test-app-0.17.0.apk
info: [debug] App already signed.
info: [debug] Zip-aligning /Users/shuai/Documents/workspace/AutoAppium/APP/selendroid-test-app-0.17.0.apk
info: [debug] Checking whether zipalign is present
info: [debug] Using zipalign from /usr/local/opt/android-sdk/build-tools/23.0.3/zipalign
info: [debug] Zip-aligning apk.
info: [debug] executing cmd: /usr/local/opt/android-sdk/build-tools/23.0.3/zipalign -f 4 /Users/shuai/Documents/workspace/AutoAppium/APP/selendroid-test-app-0.17.0.apk /var/folders/70/lygd9hmj4sl276091zn0x3700000gn/T/116717-2163-1a52oni/appium.tmp
info: [debug] App already signed.
info: [debug] Zip-aligning /tmp/selendroid.io.selendroid.testapp.apk
info: [debug] Checking whether zipalign is present
info: [debug] Using zipalign from /usr/local/opt/android-sdk/build-tools/23.0.3/zipalign
info: [debug] Zip-aligning apk.
info: [debug] executing cmd: /usr/local/opt/android-sdk/build-tools/23.0.3/zipalign -f 4 /tmp/selendroid.io.selendroid.testapp.apk /var/folders/70/lygd9hmj4sl276091zn0x3700000gn/T/116717-2163-1lt1bm6/appium.tmp
info: [debug] Rebuilt selendroid apk exists, doing nothing
info: [debug] Getting install status for io.selendroid.testapp.selendroid
info: [debug] Getting device API level
info: [debug] executing cmd: /usr/local/opt/android-sdk/platform-tools/adb -s 192.168.58.101:5555 shell "getprop ro.build.version.sdk"
info: [debug] MD5 for selendroid server is 2f991aea9839c7651e349ced8bf02337
info: [debug] Device is at API Level 16
info: [debug] executing cmd: /usr/local/opt/android-sdk/platform-tools/adb -s 192.168.58.101:5555 shell "pm list packages -3 io.selendroid.testapp.selendroid"
info: [debug] App is installed
info: [debug] Rebuilt selendroid is already installed
info: [debug] Extracting strings for language: default
info: [debug] executing cmd: /usr/local/opt/android-sdk/platform-tools/adb -s 192.168.58.101:5555 shell "getprop persist.sys.language"
info: [debug] Current device persist.sys.language: zh_cn
info: [debug] java -jar "/Applications/Appium.app/Contents/Resources/node_modules/appium/submodules/appium-adb/jars/appium_apk_tools.jar" "stringsFromApk" "/Users/shuai/Documents/workspace/AutoAppium/APP/selendroid-test-app-0.17.0.apk" "/tmp/io.selendroid.testapp" zh_cn
info: [debug] No strings.xml for language 'zh_cn', getting default strings.xml
info: [debug] java -jar "/Applications/Appium.app/Contents/Resources/node_modules/appium/submodules/appium-adb/jars/appium_apk_tools.jar" "stringsFromApk" "/Users/shuai/Documents/workspace/AutoAppium/APP/selendroid-test-app-0.17.0.apk" "/tmp/io.selendroid.testapp"
info: [debug] Reading strings from converted strings.json
info: [debug] Setting language to default
info: [debug] Not uninstalling app since server not started with --full-reset
info: [debug] Checking app cert for /Users/shuai/Documents/workspace/AutoAppium/APP/selendroid-test-app-0.17.0.apk.
info: [debug] executing cmd: java -jar /Applications/Appium.app/Contents/Resources/node_modules/appium/submodules/appium-adb/jars/verify.jar /Users/shuai/Documents/workspace/AutoAppium/APP/selendroid-test-app-0.17.0.apk
info: [debug] App already signed.
info: [debug] Zip-aligning /Users/shuai/Documents/workspace/AutoAppium/APP/selendroid-test-app-0.17.0.apk
info: [debug] Checking whether zipalign is present
info: [debug] Using zipalign from /usr/local/opt/android-sdk/build-tools/23.0.3/zipalign
info: [debug] Zip-aligning apk.
info: [debug] executing cmd: /usr/local/opt/android-sdk/build-tools/23.0.3/zipalign -f 4 /Users/shuai/Documents/workspace/AutoAppium/APP/selendroid-test-app-0.17.0.apk /var/folders/70/lygd9hmj4sl276091zn0x3700000gn/T/116717-2163-1x2pj4o/appium.tmp
info: [debug] MD5 for app is 3ed1332720445430a8dddaa9532d0f92
info: [debug] executing cmd: /usr/local/opt/android-sdk/platform-tools/adb -s 192.168.58.101:5555 shell "ls /data/local/tmp/3ed1332720445430a8dddaa9532d0f92.apk"
info: [debug] Getting install status for io.selendroid.testapp
info: [debug] Getting device API level
info: [debug] executing cmd: /usr/local/opt/android-sdk/platform-tools/adb -s 192.168.58.101:5555 shell "getprop ro.build.version.sdk"
info: [debug] Device is at API Level 16
info: [debug] executing cmd: /usr/local/opt/android-sdk/platform-tools/adb -s 192.168.58.101:5555 shell "pm list packages -3 io.selendroid.testapp"
info: [debug] App is installed
info: App is already installed, resetting app
info: [debug] Running fast reset (stop and clear)
info: [debug] executing cmd: /usr/local/opt/android-sdk/platform-tools/adb -s 192.168.58.101:5555 shell "am force-stop io.selendroid.testapp"
info: [debug] executing cmd: /usr/local/opt/android-sdk/platform-tools/adb -s 192.168.58.101:5555 shell "pm clear io.selendroid.testapp"
info: [debug] Forwarding system:8080 to device:8080
info: [debug] executing cmd: /usr/local/opt/android-sdk/platform-tools/adb -s 192.168.58.101:5555 forward tcp:8080 tcp:8080
info: [debug] Pushing settings apk to device...
info: [debug] executing cmd: /usr/local/opt/android-sdk/platform-tools/adb -s 192.168.58.101:5555 install "/Applications/Appium.app/Contents/Resources/node_modules/appium/build/settings_apk/settings_apk-debug.apk"
info: [debug] Pushing unlock helper app to device...
info: [debug] executing cmd: /usr/local/opt/android-sdk/platform-tools/adb -s 192.168.58.101:5555 install "/Applications/Appium.app/Contents/Resources/node_modules/appium/build/unlock_apk/unlock_apk-debug.apk"
info: [debug] executing cmd: /usr/local/opt/android-sdk/platform-tools/adb -s 192.168.58.101:5555 shell "dumpsys window"
info: [debug] Screen already unlocked, continuing.
info: [debug] executing cmd: /usr/local/opt/android-sdk/platform-tools/adb -s 192.168.58.101:5555 shell "am instrument -e main_activity 'io.selendroid.testapp.HomeScreenActivity' io.selendroid.testapp.selendroid/io.selendroid.server.ServerInstrumentation"
info: [debug] Making http request with opts: {"url":"http://localhost:8080/wd/hub/status","method":"GET"}
info: [debug] Selendroid server is alive!
info: [debug] Listening for Selendroid logs
info: [debug] Creating Selendroid session
info: [debug] Making http request with opts: {"url":"http://localhost:8080/wd/hub/session","method":"POST","json":{"desiredCapabilities":{"warnings":{},"desired":{"app":"/Users/shuai/Documents/workspace/AutoAppium/APP/selendroid-test-app-0.17.0.apk","newCommandTimeout":60000,"platformVersion":"4.1.1","automationName":"selendroid","app-package":"io.selendroid.androiddriver","app-activity":"io.selendroid.androiddriver.WebViewActivity","platformName":"Android","device":"Selendroid","deviceName":" "},"app":"/Users/shuai/Documents/workspace/AutoAppium/APP/selendroid-test-app-0.17.0.apk","newCommandTimeout":60000,"platformVersion":"4.1.1","automationName":"selendroid","app-package":"io.selendroid.androiddriver","app-activity":"io.selendroid.androiddriver.WebViewActivity","platformName":"Android","device":"Selendroid","deviceName":" "}}}
info: [debug] Successfully started selendroid session
info: [debug] Waiting for pkg "io.selendroid.testapp" and activity "io.selendroid.testapp.HomeScreenActivity" to be focused
info: [debug] Getting focused package and activity
info: [debug] executing cmd: /usr/local/opt/android-sdk/platform-tools/adb -s 192.168.58.101:5555 shell "dumpsys window windows"
info: [debug] Overriding session id with "731aff66-ddd6-83cf-779a-3243c638927f"
info: [debug] Device launched! Ready for commands
info: [debug] Setting command timeout to 60000 secs
info: [debug] Appium session started with sessionId 731aff66-ddd6-83cf-779a-3243c638927f
info: <-- POST /wd/hub/session 303 3760.912 ms - 74
info: --> GET /wd/hub/session/731aff66-ddd6-83cf-779a-3243c638927f {}
info: [debug] Proxying command to localhost:8080
info: [debug] Making http request with opts: {"url":"http://localhost:8080/wd/hub/session/731aff66-ddd6-83cf-779a-3243c638927f","method":"GET"}
info: [debug] Proxied response received with status 200: {"value":{"automationName":"selendroid","platform":"android","app":"/Users/shuai/Documents/workspace/AutoAppium/APP/selendroid-test-app-0.17.0.apk","acceptSslCerts":true,"javascriptEnabled":true,"browserName":"selendroid","networkConnectionEnabled":true,"rotatable":true,"desired":{"newCommandTimeout":60000,"automationName":"selendroid","app":"/Users/shuai/Documents/workspace/AutoAppium/APP/selendroid-test-app-0.17.0.apk","platformVersion":"4.1.1","platformName":"Android","deviceName":" ","app-package":"io.selendroid.androiddriver","device":"Selendroid","app-activity":"io.selendroid.androiddriver.WebViewActivity"},"version":"0.16.0","newCommandTimeout":60000,"platformVersion":"16","platformName":"android","deviceName":" ","handlesAlerts":true,"app-package":"io.selendroid.androiddriver","device":"Selendroid","app-activity":"io.selendroid.androiddriver.WebViewActivity","warnings":{},"takesScreenshot":true},"status":0,"sessionId":"731aff66-ddd6-83cf-779a-3243c638927f"}
info: <-- GET /wd/hub/session/731aff66-ddd6-83cf-779a-3243c638927f 200 15.950 ms - 979
info: --> POST /wd/hub/session/731aff66-ddd6-83cf-779a-3243c638927f/element {"using":"xpath","value":"//android.widget.Button[@text='EN Button']"}
info: [debug] Proxying command to localhost:8080
info: [debug] Making http request with opts: {"url":"http://localhost:8080/wd/hub/session/731aff66-ddd6-83cf-779a-3243c638927f/element","method":"POST","json":{"using":"xpath","value":"//android.widget.Button[@text='EN Button']"}}
info: [debug] Responding to client with error: {"status":7,"value":{"message":"An element could not be located on the page using the given search parameters.","origValue":"Element was not found."},"sessionId":"731aff66-ddd6-83cf-779a-3243c638927f"}
info: <-- POST /wd/hub/session/731aff66-ddd6-83cf-779a-3243c638927f/element 500 40.726 ms - 201
info: --> DELETE /wd/hub/session/731aff66-ddd6-83cf-779a-3243c638927f {}
info: Shutting down appium session
info: [debug] Stopping selendroid server
info: [debug] Making http request with opts: {"url":"http://localhost:8080/wd/hub/session/731aff66-ddd6-83cf-779a-3243c638927f","method":"DELETE"}
info: [debug] executing cmd: /usr/local/opt/android-sdk/platform-tools/adb -s 192.168.58.101:5555 shell "am force-stop io.selendroid.testapp"
info: [debug] Stopping logcat capture
info: [debug] Logcat terminated with code null, signal SIGTERM
info: [debug] Cleaning up appium session
info: [debug] Responding to client with success: {"status":0,"value":null,"sessionId":"731aff66-ddd6-83cf-779a-3243c638927f"}
info: <-- DELETE /wd/hub/session/731aff66-ddd6-83cf-779a-3243c638927f 200 341.662 ms - 76 {"status":0,"value":null,"sessionId":"731aff66-ddd6-83cf-779a-3243c638927f"}
希望知道的 不吝赐教 万分感谢