読者です 読者をやめる 読者になる 読者になる

つれづれなるままに。

webテストの自動化について備忘録のつもりで書いています

selendroid 0.4.2 その2(Android アプリ自動テストツール)

capabilityの設定をさぐりさぐり、牛歩のごとく。
実機で動かす前にエミュレータで動かしてみることにしてみる。

あらかじめ エミュレータを起動してたらエラーがでていた。
なので、起動せずにテストスクリプトを動かしたところ、おもむろにエミュレータを起動して・・・
起動する前にタイムアウトで落ちるという罠。

続けてもう一度テストスクリプトを動かしてみると、何と起動したではないですか!!
見ていると、そのまま テスト対象apkをインストールしてますね。

doli:selendroid_test Dolias$ java -jar selendroid-standalone-0.4.2.jar  -app ./com.android.vending-1.apk
2013/08/08 0:05:51 io.selendroid.SelendroidLauncher main
???: ################# Selendroid #################
2013/08/08 0:05:51 io.selendroid.SelendroidLauncher lauchServer
???: Starting selendroid-server port 5555
2013/08/08 0:05:51 io.selendroid.io.ShellCommand exec
???: executing command: /Users/Dolias/Devroom/android-sdk/build-tools/android-4.2.2/aapt remove /Users/Dolias/Devroom/selendroid_test/./com.android.vending-1.apk META-INF/MANIFEST.MF
2013/08/08 0:05:51 io.selendroid.io.ShellCommand exec
???: executing command: /Users/Dolias/Devroom/android-sdk/build-tools/android-4.2.2/aapt remove /Users/Dolias/Devroom/selendroid_test/./com.android.vending-1.apk META-INF/CERT.RSA
2013/08/08 0:05:51 io.selendroid.io.ShellCommand exec
???: executing command: /Users/Dolias/Devroom/android-sdk/build-tools/android-4.2.2/aapt remove /Users/Dolias/Devroom/selendroid_test/./com.android.vending-1.apk META-INF/CERT.SF
2013/08/08 0:05:51 io.selendroid.io.ShellCommand exec
???: executing command: /Users/Dolias/Devroom/android-sdk/build-tools/android-4.2.2/aapt remove /Users/Dolias/Devroom/selendroid_test/./com.android.vending-1.apk META-INF/ANDROIDD.SF
2013/08/08 0:05:51 io.selendroid.io.ShellCommand exec
???: executing command: /Users/Dolias/Devroom/android-sdk/build-tools/android-4.2.2/aapt remove /Users/Dolias/Devroom/selendroid_test/./com.android.vending-1.apk META-INF/ANDROIDD.RSA

2013/08/08 0:05:54 io.selendroid.builder.SelendroidServerBuilder signTestServer
???: App signing output: 
2013/08/08 0:05:54 io.selendroid.builder.SelendroidServerBuilder signTestServer
???: The app has been signed: /Users/Dolias/Devroom/selendroid_test/./resigned-com.android.vending-1.apk
2013/08/08 0:05:54 io.selendroid.io.ShellCommand exec
???: executing command: /Users/Dolias/Devroom/android-sdk/build-tools/android-4.2.2/aapt dump badging /Users/Dolias/Devroom/selendroid_test/./resigned-com.android.vending-1.apk
2013/08/08 0:05:54 io.selendroid.io.ShellCommand exec
???: executing command: /Users/Dolias/Devroom/android-sdk/build-tools/android-4.2.2/aapt dump badging /Users/Dolias/Devroom/selendroid_test/./resigned-com.android.vending-1.apk
2013/08/08 0:05:54 io.selendroid.server.model.SelendroidStandaloneDriver initApplicationsUnderTest
???: App com.android.vending:4.1.6 has been added to selendroid standalone server.

2013/08/08 0:05:54 io.selendroid.io.ShellCommand exec
???: executing command: /Users/Dolias/Devroom/android-sdk/tools/android list avds
2013/08/08 0:05:56 io.selendroid.server.model.DeviceStore addEmulators
???: Adding: AndroidEmulator [screenSize=800x1280, targetPlatform=ANDROID17, avdName=Nexus7]
2013/08/08 0:05:56 io.selendroid.io.ShellCommand exec
???: executing command: /Users/Dolias/Devroom/android-sdk/platform-tools/adb devices -l
2013/08/08 0:05:56 io.selendroid.server.model.DeviceStore addDevices
???: No Android devices were found.

2013/08/08 0:05:56 io.selendroid.server.SelendroidStandaloneServer start
???: selendroid-standalone server has been started on port: 5555

2013/08/08 0:06:02 io.selendroid.server.handler.CreateSessionHandler handle
???: new session command with capabilities: {"desiredCapabilities": {
  "aut": "com.android.vending:4.1.6",
  "browserName": "android",
  "cssSelectorsEnabled": false,
  "javascriptEnabled": false,
  "maxInstances": "1",
  "nativeEvents": false,
  "platform": "[\"NEXUS7\", NIL]",
  "rotatable": true,
  "takesScreenshot": true,
  "version": "5"
}}
2013/08/08 0:06:02 io.selendroid.android.impl.DefaultAndroidEmulator start
???: Using timeout of '120' seconds to start the emulator.
2013/08/08 0:06:02 io.selendroid.io.ShellCommand execAsync
???: executing async command: /Users/Dolias/Devroom/android-sdk/tools/emulator -avd Nexus7 -ports 5560,5561
2013/08/08 0:06:02 io.selendroid.io.ShellCommand exec
???: executing command: /Users/Dolias/Devroom/android-sdk/platform-tools/adb -s emulator-5560 shell getprop init.svc.bootanim
2013/08/08 0:08:03 io.selendroid.io.ShellCommand exec
???: executing command: /Users/Dolias/Devroom/android-sdk/platform-tools/adb -s emulator-5560 shell getprop init.svc.bootanim

2013/08/08 0:08:03 io.selendroid.io.ShellCommand exec
???: executing command: /Users/Dolias/Devroom/android-sdk/platform-tools/adb -s emulator-5560 emu kill
2013/08/08 0:08:03 io.selendroid.server.handler.CreateSessionHandler handle
?v???I: Error while creating new session: Error occured while interacting with the emulator: AndroidEmulator [screenSize=800x1280, targetPlatform=ANDROID17, avdName=Nexus7]: The emulator with avd 'Nexus7' was not started after 121 seconds.
2013/08/08 0:08:17 io.selendroid.server.handler.CreateSessionHandler handle
???: new session command with capabilities: {"desiredCapabilities": {
  "aut": "com.android.vending:4.1.6",
  "browserName": "android",
  "cssSelectorsEnabled": false,
  "javascriptEnabled": false,
  "maxInstances": "1",
  "nativeEvents": false,
  "platform": "[\"NEXUS7\", NIL]",
  "rotatable": true,
  "takesScreenshot": true,
  "version": "5"
}}
2013/08/08 0:08:17 io.selendroid.android.impl.DefaultAndroidEmulator start
???: Using timeout of '120' seconds to start the emulator.
2013/08/08 0:08:17 io.selendroid.io.ShellCommand execAsync
???: executing async command: /Users/Dolias/Devroom/android-sdk/tools/emulator -avd Nexus7 -ports 5560,5561
2013/08/08 0:08:17 io.selendroid.io.ShellCommand exec
???: executing command: /Users/Dolias/Devroom/android-sdk/platform-tools/adb -s emulator-5560 shell getprop init.svc.bootanim
2013/08/08 0:10:16 io.selendroid.io.ShellCommand exec
???: executing command: /Users/Dolias/Devroom/android-sdk/platform-tools/adb -s emulator-5560 shell getprop init.svc.bootanim

2013/08/08 0:10:17 io.selendroid.android.impl.DefaultAndroidEmulator start
???: Emulator start took: 119 seconds
2013/08/08 0:10:17 io.selendroid.android.impl.DefaultAndroidEmulator start
???: Please have in mind, starting an emulator takes usually about 45 seconds.

2013/08/08 0:10:17 io.selendroid.io.ShellCommand exec
???: executing command: /Users/Dolias/Devroom/android-sdk/platform-tools/adb -s emulator-5560 shell input keyevent 82
2013/08/08 0:10:26 io.selendroid.io.ShellCommand exec
???: executing command: /Users/Dolias/Devroom/android-sdk/platform-tools/adb -s emulator-5560 shell input 4
2013/08/08 0:10:29 io.selendroid.builder.SelendroidServerBuilder createSelendroidServer
???: create SelendroidServer for apk: /Users/Dolias/Devroom/selendroid_test/./resigned-com.android.vending-1.apk
2013/08/08 0:10:30 io.selendroid.builder.SelendroidServerBuilder init
???: Creating customized Selendroid-server: /var/folders/8m/ykwl2br119z5wkzwjsf31ghr0000gn/T/selendroid-server2872075215006003377.apk
2013/08/08 0:10:30 io.selendroid.io.ShellCommand exec
???: executing command: /Users/Dolias/Devroom/android-sdk/build-tools/android-4.2.2/aapt remove /var/folders/8m/ykwl2br119z5wkzwjsf31ghr0000gn/T/selendroid-server2872075215006003377.apk META-INF/CERT.RSA
2013/08/08 0:10:30 io.selendroid.io.ShellCommand exec
???: executing command: /Users/Dolias/Devroom/android-sdk/build-tools/android-4.2.2/aapt remove /var/folders/8m/ykwl2br119z5wkzwjsf31ghr0000gn/T/selendroid-server2872075215006003377.apk META-INF/CERT.SF
2013/08/08 0:10:30 io.selendroid.io.ShellCommand exec
???: executing command: /Users/Dolias/Devroom/android-sdk/build-tools/android-4.2.2/aapt remove /var/folders/8m/ykwl2br119z5wkzwjsf31ghr0000gn/T/selendroid-server2872075215006003377.apk AndroidManifest.xml
2013/08/08 0:10:30 io.selendroid.io.ShellCommand exec
???: executing command: /Users/Dolias/Devroom/android-sdk/build-tools/android-4.2.2/aapt dump badging /Users/Dolias/Devroom/selendroid_test/./resigned-com.android.vending-1.apk
2013/08/08 0:10:30 io.selendroid.builder.SelendroidServerBuilder createAndAddCustomizedAndroidManifestToSelendroidServer
???: Adding target package 'com.android.vending' to /var/folders/8m/ykwl2br119z5wkzwjsf31ghr0000gn/T/com.android.vending1375888230314/AndroidManifest.xml
2013/08/08 0:10:30 io.selendroid.io.ShellCommand exec
???: executing command: /Users/Dolias/Devroom/android-sdk/build-tools/android-4.2.2/aapt package -M /var/folders/8m/ykwl2br119z5wkzwjsf31ghr0000gn/T/com.android.vending1375888230314/AndroidManifest.xml -I /Users/Dolias/Devroom/android-sdk/platforms/android-18/android.jar -F /var/folders/8m/ykwl2br119z5wkzwjsf31ghr0000gn/T/com.android.vending1375888230314/manifest.apk -f
2013/08/08 0:10:30 io.selendroid.builder.SelendroidServerBuilder createAndAddCustomizedAndroidManifestToSelendroidServer
???: 
2013/08/08 0:10:30 io.selendroid.builder.SelendroidServerBuilder createAndAddCustomizedAndroidManifestToSelendroidServer
???: file: /var/folders/8m/ykwl2br119z5wkzwjsf31ghr0000gn/T/com.android.vending1375888230314selendroid-server.apk
2013/08/08 0:10:32 io.selendroid.builder.SelendroidServerBuilder signTestServer
???: App signing output: 
2013/08/08 0:10:32 io.selendroid.builder.SelendroidServerBuilder signTestServer
???: The app has been signed: /Users/Dolias/Devroom/selendroid_test/selendroid-server-com.android.vending-0.4.0.apk
2013/08/08 0:10:32 io.selendroid.io.ShellCommand exec
???: executing command: /Users/Dolias/Devroom/android-sdk/platform-tools/adb -s emulator-5560 shell pm list packages com.android.vending
2013/08/08 0:10:35 io.selendroid.io.ShellCommand exec
???: executing command: /Users/Dolias/Devroom/android-sdk/platform-tools/adb -s emulator-5560 uninstall com.android.vending
2013/08/08 0:10:50 io.selendroid.io.ShellCommand exec
???: executing command: /Users/Dolias/Devroom/android-sdk/platform-tools/adb -s emulator-5560 install -r /Users/Dolias/Devroom/selendroid_test/./resigned-com.android.vending-1.apk
io.selendroid.exceptions.ShellCommandException: An error occured while executing shell command: /Users/Dolias/Devroom/android-sdk/platform-tools/adb -s emulator-5560 install -r /Users/Dolias/Devroom/selendroid_test/./resigned-com.android.vending-1.apk
	at io.selendroid.io.ShellCommand.exec(ShellCommand.java:51)
	at io.selendroid.io.ShellCommand.exec(ShellCommand.java:63)
	at io.selendroid.io.ShellCommand.exec(ShellCommand.java:38)
	at io.selendroid.android.impl.AbstractDevice.executeCommand(AbstractDevice.java:116)
	at io.selendroid.android.impl.AbstractDevice.install(AbstractDevice.java:111)
	at io.selendroid.server.model.SelendroidStandaloneDriver.createNewTestSession(SelendroidStandaloneDriver.java:252)
	at io.selendroid.server.handler.CreateSessionHandler.handle(CreateSessionHandler.java:42)
	at io.selendroid.server.SelendroidServlet.handleRequest(SelendroidServlet.java:95)
	at io.selendroid.server.BaseServlet.handleHttpRequest(BaseServlet.java:81)
	at org.webbitserver.netty.NettyHttpControl.nextHandler(NettyHttpControl.java:78)
	at org.webbitserver.netty.NettyHttpControl.nextHandler(NettyHttpControl.java:62)
	at org.webbitserver.handler.PathMatchHandler.handleHttpRequest(PathMatchHandler.java:33)
	at org.webbitserver.netty.NettyHttpControl.nextHandler(NettyHttpControl.java:78)
	at org.webbitserver.netty.NettyHttpControl.nextHandler(NettyHttpControl.java:62)
	at org.webbitserver.handler.DateHeaderHandler.handleHttpRequest(DateHeaderHandler.java:21)
	at org.webbitserver.netty.NettyHttpControl.nextHandler(NettyHttpControl.java:78)
	at org.webbitserver.netty.NettyHttpControl.nextHandler(NettyHttpControl.java:62)
	at org.webbitserver.handler.ServerHeaderHandler.handleHttpRequest(ServerHeaderHandler.java:25)
	at org.webbitserver.netty.NettyHttpControl.nextHandler(NettyHttpControl.java:78)
	at org.webbitserver.netty.NettyHttpControl.nextHandler(NettyHttpControl.java:67)
	at org.webbitserver.netty.NettyHttpChannelHandler$2.run(NettyHttpChannelHandler.java:72)
	at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:895)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:918)
	at java.lang.Thread.run(Thread.java:680)
Caused by: io.selendroid.exceptions.ShellCommandException: 2404 KB/s (6041568 bytes in 2.453s)
	pkg: /data/local/tmp/resigned-com.android.vending-1.apk

	... 24 more
2013/08/08 0:11:10 io.selendroid.io.ShellCommand exec
???: executing command: /Users/Dolias/Devroom/android-sdk/build-tools/android-4.2.2/aapt dump badging /Users/Dolias/Devroom/selendroid_test/selendroid-server-com.android.vending-0.4.0.apk
2013/08/08 0:11:10 io.selendroid.io.ShellCommand exec
???: executing command: /Users/Dolias/Devroom/android-sdk/platform-tools/adb -s emulator-5560 shell pm list packages io.selendroid
2013/08/08 0:11:13 io.selendroid.io.ShellCommand exec
???: executing command: /Users/Dolias/Devroom/android-sdk/platform-tools/adb -s emulator-5560 uninstall io.selendroid
2013/08/08 0:11:16 io.selendroid.io.ShellCommand exec
???: executing command: /Users/Dolias/Devroom/android-sdk/platform-tools/adb -s emulator-5560 install -r /Users/Dolias/Devroom/selendroid_test/selendroid-server-com.android.vending-0.4.0.apk
2013/08/08 0:11:22 io.selendroid.io.ShellCommand exec
???: executing command: /Users/Dolias/Devroom/android-sdk/build-tools/android-4.2.2/aapt dump badging /Users/Dolias/Devroom/selendroid_test/./resigned-com.android.vending-1.apk
2013/08/08 0:11:22 io.selendroid.io.ShellCommand exec
???: executing command: /Users/Dolias/Devroom/android-sdk/platform-tools/adb -s emulator-5560 shell am instrument -e main_activity com.android.vending.AssetBrowserActivity io.selendroid/.ServerInstrumentation
2013/08/08 0:11:23 io.selendroid.io.ShellCommand exec
???: executing command: /Users/Dolias/Devroom/android-sdk/platform-tools/adb -s emulator-5560 forward tcp:38080 tcp:8080
2013/08/08 0:11:23 io.selendroid.android.impl.AbstractDevice isSelendroidRunning
???: using url: http://localhost:38080/wd/hub/status
2013/08/08 0:11:24 io.selendroid.android.impl.AbstractDevice isSelendroidRunning
???: got response status code: 200
2013/08/08 0:11:24 io.selendroid.android.impl.AbstractDevice isSelendroidRunning
???: got response value: {status: 0, value: {"supportedApps":[],"build":{"browserName":"selendroid","version":"0.4.2"},"os":{"arch":"x86","version":"17","name":"Android"},"supportedDevices":[]}}
2013/08/08 0:11:25 io.selendroid.server.util.HttpClientUtil executeCreateSessionRequest
???: creating session by using url: http://localhost:38080/wd/hub/session
Create new session response: {
  "sessionId": "a6c2fe96-826f-469f-9628-c1122da37267",
  "status": 0,
  "value": {
    "aut": "com.android.vending:4.1.6",
    "browserName": "android",
    "cssSelectorsEnabled": false,
    "javascriptEnabled": false,
    "maxInstances": "1",
    "nativeEvents": false,
    "platform": "[\"NEXUS7\", NIL]",
    "rotatable": true,
    "takesScreenshot": true,
    "version": "5"
  }
}
new Session URL: http://localhost:5555/wd/hub/session/a6c2fe96-826f-469f-9628-c1122da37267

ちょっと前進した?
ちなみに、タイムアウトしてしまうエミュレータは コマンドラインパラメータでタイムアウト時間を変更できるそうな。