Appium selendroid 模式下运行样例报 Failed to start an Appium session

财经 · 2015年01月07日 · 最后由 恒温 回复于 2015年01月08日 · 1371 次阅读

java 脚本内容如下:
public class AppDemo {

private AndroidDriver driver;

@Before
public void setUp() throws Exception {
// set up appium
File classpathRoot = new File(System.getProperty("user.dir"));
File appDir = new File(classpathRoot, "./app");
File app = new File(appDir, "ContactManagerselendroid.apk");
DesiredCapabilities capabilities = new DesiredCapabilities();
capabilities.setCapability(CapabilityType.BROWSER_NAME, "");
capabilities.setCapability("platformName", "Android");
capabilities.setCapability("deviceName","fa52262d");
capabilities.setCapability("platformVersion", "4.1");
capabilities.setCapability("app", app.getAbsolutePath());
capabilities.setCapability("appPackage", "com.example.android.contactmanager");
capabilities.setCapability("appActivity", ".ContactManagerselendroid");
capabilities.setCapability("automationName","selendroid");
driver = new AndroidDriver(new URL("http://127.0.0.1:4723/wd/hub"), capabilities);
}

@After
public void tearDown() throws Exception {
driver.quit();
}

@Test
public void addContact(){
WebElement el = driver.findElement(By.name("Add Contact"));
el.click();
List textFieldsList = driver.findElementsByClassName("android.widget.EditText");
textFieldsList.get(0).sendKeys("Some Name");
textFieldsList.get(2).sendKeys("Some@example.com");
driver.swipe(10, 10, 10, 10, 1);
driver.findElementByName("Save").click();
}

}
===================appium 的 selendroid 模式下日志内容如下===================================

Starting Node Server
info: Welcome to Appium v1.3.4 (REV c8c79a85fbd6870cd6fc3d66d038a115ebe22efe)
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":"16","automationName":"Selendroid"}
info: Console LogLevel: debug
info: --> POST /wd/hub/session {"desiredCapabilities":{"automationName":"selendroid","platformVersion":"4.1","app":"E:\workspace\myAppium.\app\ContactManagerselendroid.apk","platformName":"Android","deviceName":"fa52262d","browserName":"","appActivity":".ContactManagerselendroid","appPackage":"com.example.android.contactmanager"}}
info: Client User-Agent string: Apache-HttpClient/4.3.4 (java 1.5)
info: [debug] Using local app from desired caps: E:\workspace\myAppium\app\ContactManagerselendroid.apk
info: [debug] Creating new appium session dda5f107-2fe3-481a-94bf-248ad7bf0d22
info: [debug] Starting selendroid server
info: [debug] Getting Java version
info: Java version is: 1.7.0_65
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: [debug] Checking whether adb is present
info: [debug] Using adb from F:\android_sdk\platform-tools\adb.exe
info: Retrieving device
info: [debug] Trying to find a connected android device
info: [debug] Getting connected devices...
info: [debug] executing cmd: F:\android_sdk\platform-tools\adb.exe devices
info: [debug] 1 device(s) connected
info: Found device cfcc43fd
info: [debug] Setting device id to cfcc43fd
info: [debug] Waiting for device to be ready and to respond to shell commands (timeout = 5)
info: [debug] executing cmd: F:\android_sdk\platform-tools\adb.exe -s cfcc43fd wait-for-device
info: [debug] executing cmd: F:\android_sdk\platform-tools\adb.exe -s cfcc43fd shell "echo 'ready'"
info: [debug] Starting logcat capture
info: [debug] Checking whether aapt is present
info: [debug] Using aapt from F:\android_sdk\build-tools\21.1.2\aapt.exe
info: [debug] Checking if has internet permission from manifest.
info: [debug] executing cmd: F:\android_sdk\build-tools\21.1.2\aapt.exe dump badging E:\workspace\myAppium\app\ContactManagerselendroid.apk
info: [debug] Rebuilt selendroid server already exists, no need to rebuild it with a new manifest
info: [debug] Checking signed status of C:\Users\CHENGH~1\AppData\Local\Temp\selendroid.com.example.android.contactmanager.apk
info: [debug] Checking app cert for C:\Users\CHENGH~1\AppData\Local\Temp\selendroid.com.example.android.contactmanager.apk.
info: [debug] executing cmd: java -jar F:\appium\AppiumForWindows-1.3.4.1\node_modules\appium\node_modules\appium-adb\jars\verify.jar C:\Users\CHENGH~1\AppData\Local\Temp\selendroid.com.example.android.contactmanager.apk
info: [debug] Checking signed status of E:\workspace\myAppium\app\ContactManagerselendroid.apk
info: [debug] Checking app cert for E:\workspace\myAppium\app\ContactManagerselendroid.apk.
info: [debug] executing cmd: java -jar F:\appium\AppiumForWindows-1.3.4.1\node_modules\appium\node_modules\appium-adb\jars\verify.jar E:\workspace\myAppium\app\ContactManagerselendroid.apk
info: [debug] App already signed.
info: [debug] Zip-aligning E:\workspace\myAppium\app\ContactManagerselendroid.apk
info: [debug] Checking whether zipalign is present
info: [debug] Using zipalign from F:\android_sdk\build-tools\21.1.2\zipalign.exe
info: [debug] Zip-aligning apk.
info: [debug] executing cmd: F:\android_sdk\build-tools\21.1.2\zipalign.exe -f 4 E:\workspace\myAppium\app\ContactManagerselendroid.apk C:\Users\CHENGH~1\AppData\Local\Temp\appium11506-8028-1b6azw5.tmp
info: [debug] App already signed.
info: [debug] Zip-aligning C:\Users\CHENGH~1\AppData\Local\Temp\selendroid.com.example.android.contactmanager.apk
info: [debug] Checking whether zipalign is present
info: [debug] Using zipalign from F:\android_sdk\build-tools\21.1.2\zipalign.exe
info: [debug] Zip-aligning apk.
info: [debug] executing cmd: F:\android_sdk\build-tools\21.1.2\zipalign.exe -f 4 C:\Users\CHENGH~1\AppData\Local\Temp\selendroid.com.example.android.contactmanager.apk C:\Users\CHENGH~1\AppData\Local\Temp\appium11506-8028-1p39k07.tmp
info: [debug] Rebuilt selendroid apk does not exist, uninstalling any instances of it on device to make way for new one
info: [debug] Uninstalling com.example.android.contactmanager.selendroid
info: [debug] executing cmd: F:\android_sdk\platform-tools\adb.exe -s cfcc43fd shell "am force-stop com.example.android.contactmanager.selendroid"
info: [debug] executing cmd: F:\android_sdk\platform-tools\adb.exe -s cfcc43fd uninstall com.example.android.contactmanager.selendroid
info: [debug] App was uninstalled
info: [debug] Getting install status for com.example.android.contactmanager.selendroid
info: [debug] Getting device API level
info: [debug] executing cmd: F:\android_sdk\platform-tools\adb.exe -s cfcc43fd shell "getprop ro.build.version.sdk"
info: [debug] Device is at API Level 16
info: [debug] executing cmd: F:\android_sdk\platform-tools\adb.exe -s cfcc43fd shell "pm list packages -3 com.example.android.contactmanager.selendroid"
info: [debug] App is not installed
info: [debug] Rebuilt selendroid is not installed, installing it
info: [debug] executing cmd: F:\android_sdk\platform-tools\adb.exe -s cfcc43fd install -r "C:\Users\CHENGH~1\AppData\Local\Temp\selendroid.com.example.android.contactmanager.apk"
info: [debug] executing cmd: F:\android_sdk\platform-tools\adb.exe -s cfcc43fd shell "getprop persist.sys.language"
info: [debug] Current device persist.sys.language: zh
info: [debug] java -jar "F:\appium\AppiumForWindows-1.3.4.1\node_modules\appium\node_modules\appium-adb\jars\appium_apk_tools.jar" "stringsFromApk" "E:\workspace\myAppium\app\ContactManagerselendroid.apk" "C:\Users\CHENGH~1\AppData\Local\Temp\com.example.android.contactmanager" zh
info: [debug] No strings.xml for language 'zh', getting default strings.xml
info: [debug] java -jar "F:\appium\AppiumForWindows-1.3.4.1\node_modules\appium\node_modules\appium-adb\jars\appium_apk_tools.jar" "stringsFromApk" "E:\workspace\myAppium\app\ContactManagerselendroid.apk" "C:\Users\CHENGH~1\AppData\Local\Temp\com.example.android.contactmanager"
info: [debug] Not uninstalling app since server not started with --full-reset
info: [debug] Checking app cert for E:\workspace\myAppium\app\ContactManagerselendroid.apk.
info: [debug] executing cmd: java -jar F:\appium\AppiumForWindows-1.3.4.1\node_modules\appium\node_modules\appium-adb\jars\verify.jar E:\workspace\myAppium\app\ContactManagerselendroid.apk
info: [debug] App already signed.
info: [debug] Zip-aligning E:\workspace\myAppium\app\ContactManagerselendroid.apk
info: [debug] Checking whether zipalign is present
info: [debug] Using zipalign from F:\android_sdk\build-tools\21.1.2\zipalign.exe
info: [debug] Zip-aligning apk.
info: [debug] executing cmd: F:\android_sdk\build-tools\21.1.2\zipalign.exe -f 4 E:\workspace\myAppium\app\ContactManagerselendroid.apk C:\Users\CHENGH~1\AppData\Local\Temp\appium11506-8028-14u0p7p.tmp
info: [debug] MD5 for app is 6d2ffe9de6e0da4dac74094e843664ce
info: [debug] executing cmd: F:\android_sdk\platform-tools\adb.exe -s cfcc43fd shell "ls /data/local/tmp/6d2ffe9de6e0da4dac74094e843664ce.apk"
info: [debug] Getting install status for com.example.android.contactmanager
info: [debug] Getting device API level
info: [debug] executing cmd: F:\android_sdk\platform-tools\adb.exe -s cfcc43fd shell "getprop ro.build.version.sdk"
info: [debug] Device is at API Level 16
info: [debug] executing cmd: F:\android_sdk\platform-tools\adb.exe -s cfcc43fd shell "pm list packages -3 com.example.android.contactmanager"
info: [debug] App is installed
info: App is already installed, resetting app
info: [debug] Running fast reset (stop and clear)
info: [debug] executing cmd: F:\android_sdk\platform-tools\adb.exe -s cfcc43fd shell "am force-stop com.example.android.contactmanager"
info: [debug] executing cmd: F:\android_sdk\platform-tools\adb.exe -s cfcc43fd shell "pm clear com.example.android.contactmanager"
info: [debug] Forwarding system:8080 to device:8080
info: [debug] executing cmd: F:\android_sdk\platform-tools\adb.exe -s cfcc43fd forward tcp:8080 tcp:8080
info: [debug] Pushing settings apk to device...
info: [debug] executing cmd: F:\android_sdk\platform-tools\adb.exe -s cfcc43fd install "F:\appium\AppiumForWindows-1.3.4.1\node_modules\appium\build\settings_apk\settings_apk-debug.apk"
info: [debug] Pushing unlock helper app to device...
info: [debug] executing cmd: F:\android_sdk\platform-tools\adb.exe -s cfcc43fd install "F:\appium\AppiumForWindows-1.3.4.1\node_modules\appium\build\unlock_apk\unlock_apk-debug.apk"
info: [debug] executing cmd: F:\android_sdk\platform-tools\adb.exe -s cfcc43fd shell "dumpsys window"
info: [debug] Screen already unlocked, continuing.
info: [debug] executing cmd: F:\android_sdk\platform-tools\adb.exe -s cfcc43fd shell "am instrument -e main_activity 'com.example.android.contactmanager.ContactManagerselendroid' com.example.android.contactmanager.selendroid/io.selendroid.ServerInstrumentation"
info: [debug] Making http request with opts: {"url":"http://localhost:8080/wd/hub/status,method:GET"}
info: [debug] Making http request with opts: {"url":"http://localhost:8080/wd/hub/status,method:GET"}
info: [debug] Making http request with opts: {"url":"http://localhost:8080/wd/hub/status,method:GET"}
info: [debug] Making http request with opts: {"url":"http://localhost:8080/wd/hub/status,method:GET"}
info: [debug] Making http request with opts: {"url":"http://localhost:8080/wd/hub/status,method:GET"}
info: [debug] Making http request with opts: {"url":"http://localhost:8080/wd/hub/status,method:GET"}
info: [debug] Making http request with opts: {"url":"http://localhost:8080/wd/hub/status,method:GET"}
info: [debug] Making http request with opts: {"url":"http://localhost:8080/wd/hub/status,method:GET"}
info: [debug] Making http request with opts: {"url":"http://localhost:8080/wd/hub/status,method:GET"}
info: [debug] Making http request with opts: {"url":"http://localhost:8080/wd/hub/status,method:GET"}
info: [debug] Making http request with opts: {"url":"http://localhost:8080/wd/hub/status,method:GET"}
info: [debug] Making http request with opts: {"url":"http://localhost:8080/wd/hub/status,method:GET"}
info: [debug] Making http request with opts: {"url":"http://localhost:8080/wd/hub/status,method:GET"}
info: [debug] Making http request with opts: {"url":"http://localhost:8080/wd/hub/status,method:GET"}
info: [debug] Making http request with opts: {"url":"http://localhost:8080/wd/hub/status,method:GET"}
info: [debug] Making http request with opts: {"url":"http://localhost:8080/wd/hub/status,method:GET"}
info: [debug] Making http request with opts: {"url":"http://localhost:8080/wd/hub/status,method:GET"}
info: [debug] Making http request with opts: {"url":"http://localhost:8080/wd/hub/status,method:GET"}
info: [debug] Making http request with opts: {"url":"http://localhost:8080/wd/hub/status,method:GET"}
info: [debug] Making http request with opts: {"url":"http://localhost:8080/wd/hub/status,method:GET"}
info: [debug] Making http request with opts: {"url":"http://localhost:8080/wd/hub/status,method:GET"}
info: [debug] Making http request with opts: {"url":"http://localhost:8080/wd/hub/status,method:GET"}
info: [debug] Making http request with opts: {"url":"http://localhost:8080/wd/hub/status,method:GET"}
info: [debug] Making http request with opts: {"url":"http://localhost:8080/wd/hub/status,method:GET"}
info: [debug] Making http request with opts: {"url":"http://localhost:8080/wd/hub/status,method:GET"}
info: [debug] Making http request with opts: {"url":"http://localhost:8080/wd/hub/status,method:GET"}
info: [debug] Cleaning up appium session
info: [debug] Error: Waited 20 secs for selendroid server and it never showed up
at F:\appium\AppiumForWindows-1.3.4.1\node_modules\appium\lib\devices\android\selendroid.js:338:14
at Request._callback (F:\appium\AppiumForWindows-1.3.4.1\node_modules\appium\lib\devices\common.js:121:5)
at self.callback (F:\appium\AppiumForWindows-1.3.4.1\node_modules\appium\node_modules\request\request.js:121:22)
at Request.EventEmitter.emit (events.js:95:17)
at ClientRequest.self.clientErrorHandler (F:\appium\AppiumForWindows-1.3.4.1\node_modules\appium\node_modules\request\request.js:230:10)
at ClientRequest.EventEmitter.emit (events.js:95:17)
at Socket.socketErrorListener (http.js:1547:9)
at Socket.EventEmitter.emit (events.js:95:17)
at net.js:440:14
at process._tickDomainCallback (node.js:459:13)
info: [debug] Responding to client with error: {"status":33,"value":{"message":"A new session could not be created. (Original error: Waited 20 secs for selendroid server and it never showed up)","origValue":"Waited 20 secs for selendroid server and it never showed up"},"sessionId":null}
info: <-- POST /wd/hub/session 500 38701.063 ms - 240
error: Failed to start an Appium session, err was: Error: Waited 20 secs for selendroid server and it never showed up

请知道的朋友告诉我一下原因,谢谢

共收到 13 条回复 时间 点赞

重复发帖是什么意思啊?

info: [debug] executing cmd: F:\android_sdk\platform-tools\adb.exe -s cfcc43fd shell "am instrument -e main_activity 'com.example.android.contactmanager.ContactManagerselendroid'

确定是这个 activity 么?

发帖规范啊。。。

capabilities.setCapability("appActivity", ".ContactManagerselendroid");
明显不是这样子的

#4 楼 @xuxu 请问应该是怎么写?

#1 楼 @lihuazhang 一开始是在新人区发的,过了一天见没人回,以为要到 appium 区来发,所以发重复了

#2 楼 @lihuazhang 我是从官网上下的一个正对 selendroid 的 app

#7 楼 @huangcheng 这个 app 的链接给我看看

#7 楼 @huangcheng 你真是一塌糊涂,头像没有头像,发帖也不遵守规矩。 你怎么做测试的啊?

财经 #11 · 2015年01月08日 Author

#9 楼 @lihuazhang 头像已加咯,公司网络不知道怎么搞的老是限制,编辑页面打开各种 JS 错误,下次发帖子我尽量做个好市民

#10 楼 @huangcheng

➜  Downloads  aapt dump badging ~/Downloads/ContactManager-selendroid.apk
package: name='com.example.android.contactmanager' versionCode='1' versionName='1.0'
sdkVersion:'5'
targetSdkVersion:'5'
uses-permission:'android.permission.GET_ACCOUNTS'
uses-permission:'android.permission.READ_CONTACTS'
uses-permission:'android.permission.WRITE_CONTACTS'
uses-permission:'android.permission.INTERNET'
application-label:'Contact Manager'
application-icon-120:'res/drawable-ldpi/icon.png'
application-icon-160:'res/drawable-mdpi/icon.png'
application-icon-240:'res/drawable-hdpi/icon.png'
application: label='Contact Manager' icon='res/drawable-mdpi/icon.png'
application-debuggable
launchable-activity: name='com.example.android.contactmanager.ContactManager'  label='Contact Manager' icon=''
uses-permission:'android.permission.READ_CALL_LOG'
uses-implied-permission:'android.permission.READ_CALL_LOG','targetSdkVersion < 16 and requested READ_CONTACTS'
uses-permission:'android.permission.WRITE_CALL_LOG'
uses-implied-permission:'android.permission.WRITE_CALL_LOG','targetSdkVersion < 16 and requested WRITE_CONTACTS'
uses-feature:'android.hardware.touchscreen'
uses-implied-feature:'android.hardware.touchscreen','assumed you require a touch screen unless explicitly made optional'
main
other-activities
supports-screens: 'small' 'normal' 'large'
supports-any-density: 'true'
locales: '--_--'
densities: '120' '160' '240'

财经 #13 · 2015年01月08日 Author

#12 楼 @lihuazhang 除了包名称我去掉了一个-,不知道其他位置是否哪地方不对?忘高人明示

需要 登录 后方可回复, 如果你还没有账号请点击这里 注册