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

つれづれなるままに。

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

Selendroid 0.4.2 を使って Nexus7で自動テストスクリプトを動かしてみる

実際に動かすところまでがんばってみる。

ANDROID_HOME JAVA_HOME の設定を profile内でやっていないので、手動で行った。

doli:selendroid_test Dolias$ export ANDROID_HOME=/Users/Dolias/Devroom/android-sdk
doli:selendroid_test Dolias$ export JAVA_HOME=`/usr/libexec/java_home`
doli:selendroid_test Dolias$ java -jar selendroid-standalone-0.4.2.jar -app ./com.android.vending-1.apk
2013/08/03 20:51:45 io.selendroid.SelendroidLauncher main
???: ################# Selendroid #################
2013/08/03 20:51:45 io.selendroid.SelendroidLauncher lauchServer
???: Starting selendroid-server port 5555
2013/08/03 20:51:45 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/03 20:51:45 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/03 20:51:45 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/03 20:51:45 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/03 20:51:45 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/03 20:51:47 io.selendroid.builder.SelendroidServerBuilder signTestServer
???: App signing output: 
2013/08/03 20:51:47 io.selendroid.builder.SelendroidServerBuilder signTestServer
???: The app has been signed: /Users/Dolias/Devroom/selendroid_test/./resigned-com.android.vending-1.apk
2013/08/03 20:51:47 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/03 20:51:48 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/03 20:51:48 io.selendroid.server.model.SelendroidStandaloneDriver initApplicationsUnderTest
???: App com.android.vending:4.1.6 has been added to selendroid standalone server.
2013/08/03 20:51:48 io.selendroid.io.ShellCommand exec
???: executing command: /Users/Dolias/Devroom/android-sdk/tools/android list avds
2013/08/03 20:51:50 io.selendroid.server.model.DeviceStore addEmulators
???: Adding: AndroidEmulator [screenSize=WVGA854, targetPlatform=ANDROID17, avdName=titanium_10_WVGA854]
2013/08/03 20:51:50 io.selendroid.server.model.DeviceStore addEmulators
???: Adding: AndroidEmulator [screenSize=WVGA854, targetPlatform=ANDROID17, avdName=titanium_5_WVGA854]
2013/08/03 20:51:50 io.selendroid.server.model.DeviceStore addEmulators
???: Adding: AndroidEmulator [screenSize=, targetPlatform=null, avdName=titanium_5_WVGA854_armeabi-v7a]
2013/08/03 20:51:50 io.selendroid.server.model.DeviceStore addEmulators
???: Adding: AndroidEmulator [screenSize=, targetPlatform=null, avdName=titanium_6_WVGA854]
2013/08/03 20:51:50 io.selendroid.io.ShellCommand exec
???: executing command: /Users/Dolias/Devroom/android-sdk/platform-tools/adb devices -l
2013/08/03 20:51:50 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/03 20:51:50 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/03 20:51:51 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/03 20:51:51 io.selendroid.server.SelendroidStandaloneServer start
???: selendroid-standalone server has been started on port: 5555

ステータスを確認してみる

http://localhost:5555/wd/hub/status

{
    status: 0,
    value: {
        "supportedApps": [{
            "appId": "com.android.vending:4.1.6",
            "mainActivity": "com.android.vending.AssetBrowserActivity",
            "basePackage": "com.android.vending"
        }],
        "os": {
            "arch": "x86_64",
            "name": "Mac OS X",
            "version": "10.8.4"
        },
        "build": {
            "browserName": "selendroid",
            "version": "0.4.2"
        },
        "supportedDevices": [{
            "screenSize": "",
            "emulator": true,
            "avdName": "titanium_5_WVGA854_armeabi-v7a"
        }, {
            "screenSize": "",
            "emulator": true,
            "avdName": "titanium_6_WVGA854"
        }, {
            "screenSize": "800x1280",
            "model": "Nexus 7",
            "emulator": false
        }, {
            "screenSize": "WVGA854",
            "targetPlatform": "ANDROID17",
            "emulator": true,
            "avdName": "titanium_10_WVGA854"
        }, {
            "screenSize": "WVGA854",
            "targetPlatform": "ANDROID17",
            "emulator": true,
            "avdName": "titanium_5_WVGA854"
        }]
    }
}

なにかあやしい。

テストスクリプトは 

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.model = "Nexus 7"
    caps.proxy = nil
    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 teardown
    @driver.quit
  end
end

とりあえず、起動だけでも、と思ったが・・・

$ ruby test.rb 
Run options: 

# Running tests:



Finished tests in 0.000457s, 0.0000 tests/s, 0.0000 assertions/s.

0 tests, 0 assertions, 0 failures, 0 errors, 0 skips

あれ? capabilitiesが間違っている気がする。

続く・・・ (おい!