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

つれづれなるままに。

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

selendroid 0.4.2 その3

前回は エミュレータを試しましたがあまりの遅さにタイムアウトがでてます。

なので、今回は実機を接続して挑戦。目標はアプリの起動です(レベルが低い・・・)



サーバー側の起動です

doli:selendroid_test Dolias$ java -jar selendroid-standalone-0.4.2.jar -app ./jp.co.yahoo.android.yfiler-1.apk
2013/08/08 22:13:44 io.selendroid.SelendroidLauncher main
???: ################# Selendroid #################
2013/08/08 22:13:44 io.selendroid.SelendroidLauncher lauchServer
???: Starting selendroid-server port 5555
2013/08/08 22:13:44 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/./jp.co.yahoo.android.yfiler-1.apk META-INF/MANIFEST.MF
2013/08/08 22:13:44 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/./jp.co.yahoo.android.yfiler-1.apk META-INF/CERT.RSA
2013/08/08 22:13:44 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/./jp.co.yahoo.android.yfiler-1.apk META-INF/CERT.SF
2013/08/08 22:13:44 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/./jp.co.yahoo.android.yfiler-1.apk META-INF/ANDROIDD.SF
2013/08/08 22:13:44 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/./jp.co.yahoo.android.yfiler-1.apk META-INF/ANDROIDD.RSA
2013/08/08 22:13:45 io.selendroid.builder.SelendroidServerBuilder signTestServer
???: App signing output: 
2013/08/08 22:13:45 io.selendroid.builder.SelendroidServerBuilder signTestServer
???: The app has been signed: /Users/Dolias/Devroom/selendroid_test/./resigned-jp.co.yahoo.android.yfiler-1.apk
2013/08/08 22:13:45 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-jp.co.yahoo.android.yfiler-1.apk
2013/08/08 22:13:45 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-jp.co.yahoo.android.yfiler-1.apk
2013/08/08 22:13:45 io.selendroid.server.model.SelendroidStandaloneDriver initApplicationsUnderTest
???: App jp.co.yahoo.android.yfiler:1.0.6 has been added to selendroid standalone server.
2013/08/08 22:13:45 io.selendroid.io.ShellCommand exec
???: executing command: /Users/Dolias/Devroom/android-sdk/tools/android list avds
2013/08/08 22:13:47 io.selendroid.server.model.DeviceStore addEmulators
???: Adding: AndroidEmulator [screenSize=800x1280, targetPlatform=ANDROID17, avdName=Nexus7]
2013/08/08 22:13:47 io.selendroid.io.ShellCommand exec
???: executing command: /Users/Dolias/Devroom/android-sdk/platform-tools/adb devices -l
2013/08/08 22:13:47 io.selendroid.io.ShellCommand exec
???: executing command: /Users/Dolias/Devroom/android-sdk/platform-tools/adb -s 015d24bc784c1214 shell getprop ro.build.version.sdk
2013/08/08 22:13:47 io.selendroid.io.ShellCommand exec
???: executing command: /Users/Dolias/Devroom/android-sdk/platform-tools/adb -s 015d24bc784c1214 shell getprop ro.build.version.sdk
2013/08/08 22:13:47 io.selendroid.server.SelendroidStandaloneServer start
???: selendroid-standalone server has been started on port: 5555

テストスクリプトを実行させます

require 'rubygems'
require "test/unit"
require 'selenium-webdriver'
require 'json'

class ExampleTest < Test::Unit::TestCase

  def setup
    caps = Selenium::WebDriver::Remote::Capabilities.android
    caps.version = "5"
 	caps.platform  = "Nexus7",
    caps.proxy = nil
    caps[:aut]="jp.co.yahoo.android.yfiler:1.0.6"
    caps[:maxInstances]="1"
    
    client = Selenium::WebDriver::Remote::Http::Default.new
    client.timeout = 120 # seconds
    
    @driver = Selenium::WebDriver.for(
    :remote, :http_client => client,
    :url => "http://localhost:5555/wd/hub",
    :desired_capabilities => caps)
  end

  def test_size
    assert_equal('abc'.size, 3)
  end
  
  def teardown
    @driver.quit
  end
end

2013/08/08 22:14:07 io.selendroid.server.handler.CreateSessionHandler handle
???: new session command with capabilities: {"desiredCapabilities": {
  "aut": "jp.co.yahoo.android.yfiler:1.0.6",
  "browserName": "android",
  "cssSelectorsEnabled": false,
  "javascriptEnabled": false,
  "maxInstances": "1",
  "nativeEvents": false,
  "platform": "[\"NEXUS7\", NIL]",
  "rotatable": true,
  "takesScreenshot": true,
  "version": "5"
}}
2013/08/08 22:14:07 io.selendroid.builder.SelendroidServerBuilder createSelendroidServer
???: create SelendroidServer for apk: /Users/Dolias/Devroom/selendroid_test/./resigned-jp.co.yahoo.android.yfiler-1.apk
2013/08/08 22:14:07 io.selendroid.builder.SelendroidServerBuilder init
???: Creating customized Selendroid-server: /var/folders/8m/ykwl2br119z5wkzwjsf31ghr0000gn/T/selendroid-server3408469448389316417.apk
2013/08/08 22:14:07 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-server3408469448389316417.apk META-INF/CERT.RSA
2013/08/08 22:14:07 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-server3408469448389316417.apk META-INF/CERT.SF
2013/08/08 22:14:07 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-server3408469448389316417.apk AndroidManifest.xml
2013/08/08 22:14:07 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-jp.co.yahoo.android.yfiler-1.apk
2013/08/08 22:14:07 io.selendroid.builder.SelendroidServerBuilder createAndAddCustomizedAndroidManifestToSelendroidServer
???: Adding target package 'jp.co.yahoo.android.yfiler' to /var/folders/8m/ykwl2br119z5wkzwjsf31ghr0000gn/T/jp.co.yahoo.android.yfiler1375967647512/AndroidManifest.xml
2013/08/08 22:14:07 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/jp.co.yahoo.android.yfiler1375967647512/AndroidManifest.xml -I /Users/Dolias/Devroom/android-sdk/platforms/android-18/android.jar -F /var/folders/8m/ykwl2br119z5wkzwjsf31ghr0000gn/T/jp.co.yahoo.android.yfiler1375967647512/manifest.apk -f
2013/08/08 22:14:07 io.selendroid.builder.SelendroidServerBuilder createAndAddCustomizedAndroidManifestToSelendroidServer
???: 
2013/08/08 22:14:07 io.selendroid.builder.SelendroidServerBuilder createAndAddCustomizedAndroidManifestToSelendroidServer
???: file: /var/folders/8m/ykwl2br119z5wkzwjsf31ghr0000gn/T/jp.co.yahoo.android.yfiler1375967647512selendroid-server.apk
2013/08/08 22:14:08 io.selendroid.builder.SelendroidServerBuilder signTestServer
???: App signing output: 
2013/08/08 22:14:08 io.selendroid.builder.SelendroidServerBuilder signTestServer
???: The app has been signed: /Users/Dolias/Devroom/selendroid_test/selendroid-server-jp.co.yahoo.android.yfiler-0.4.0.apk
2013/08/08 22:14:08 io.selendroid.io.ShellCommand exec
???: executing command: /Users/Dolias/Devroom/android-sdk/platform-tools/adb -s 015d24bc784c1214 shell pm list packages jp.co.yahoo.android.yfiler
2013/08/08 22:14:09 io.selendroid.io.ShellCommand exec
???: executing command: /Users/Dolias/Devroom/android-sdk/platform-tools/adb -s 015d24bc784c1214 uninstall jp.co.yahoo.android.yfiler
2013/08/08 22:14:10 io.selendroid.io.ShellCommand exec
???: executing command: /Users/Dolias/Devroom/android-sdk/platform-tools/adb -s 015d24bc784c1214 install -r /Users/Dolias/Devroom/selendroid_test/./resigned-jp.co.yahoo.android.yfiler-1.apk
2013/08/08 22:14:18 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-jp.co.yahoo.android.yfiler-0.4.0.apk
2013/08/08 22:14:18 io.selendroid.io.ShellCommand exec
???: executing command: /Users/Dolias/Devroom/android-sdk/platform-tools/adb -s 015d24bc784c1214 shell pm list packages io.selendroid
2013/08/08 22:14:19 io.selendroid.io.ShellCommand exec
???: executing command: /Users/Dolias/Devroom/android-sdk/platform-tools/adb -s 015d24bc784c1214 uninstall io.selendroid
2013/08/08 22:14:21 io.selendroid.io.ShellCommand exec
???: executing command: /Users/Dolias/Devroom/android-sdk/platform-tools/adb -s 015d24bc784c1214 install -r /Users/Dolias/Devroom/selendroid_test/selendroid-server-jp.co.yahoo.android.yfiler-0.4.0.apk
2013/08/08 22:14:24 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-jp.co.yahoo.android.yfiler-1.apk
2013/08/08 22:14:24 io.selendroid.io.ShellCommand exec
???: executing command: /Users/Dolias/Devroom/android-sdk/platform-tools/adb -s 015d24bc784c1214 shell am instrument -e main_activity jp.co.yahoo.android.yfiler.YFHandleActivity io.selendroid/.ServerInstrumentation
2013/08/08 22:14:25 io.selendroid.io.ShellCommand exec
???: executing command: /Users/Dolias/Devroom/android-sdk/platform-tools/adb -s 015d24bc784c1214 forward tcp:38080 tcp:8080
2013/08/08 22:14:25 io.selendroid.android.impl.AbstractDevice isSelendroidRunning
???: using url: http://localhost:38080/wd/hub/status
Cleaning up unclosed ZipFile for archive /var/folders/8m/ykwl2br119z5wkzwjsf31ghr0000gn/T/selendroid-server3408469448389316417.apk
2013/08/08 22:14:25 io.selendroid.android.impl.AbstractDevice isSelendroidRunning
???: got response status code: 200
2013/08/08 22:14:25 io.selendroid.android.impl.AbstractDevice isSelendroidRunning
???: got response value: {status: 0, value: {"supportedApps":[],"build":{"browserName":"selendroid","version":"0.4.2"},"os":{"arch":"armeabi-v7a","version":"18","name":"Android"},"supportedDevices":[]}}
2013/08/08 22:14:26 io.selendroid.server.util.HttpClientUtil executeCreateSessionRequest
???: creating session by using url: http://localhost:38080/wd/hub/session
Create new session response: {
  "sessionId": "35aab316-0c05-4fc8-b1e5-6785a9621e4f",
  "status": 0,
  "value": {
    "aut": "jp.co.yahoo.android.yfiler:1.0.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/35aab316-0c05-4fc8-b1e5-6785a9621e4f
2013/08/08 22:14:27 io.selendroid.server.handler.GetCapabilities handle
???: get capabilities command
2013/08/08 22:14:27 io.selendroid.server.handler.DeleteSessionHandler handle
???: delete session command

アプリが起動することを確認できました!

とりあえず動かないことは話が始まらない。設定の意味を調べていくフェーズに移れそうです。