LoginSignup
3
3

More than 5 years have passed since last update.

AppiumRubyConsole(ARC)を使ってiOSシミュレーターを動かしてみた。

Last updated at Posted at 2017-05-15

概要

原文

Appium is an open source, cross-platform test automation tool for native, hybrid and mobile web apps, tested on simulators (iOS, FirefoxOS), emulators (Android), and real devices (iOS, Android, Windows, FirefoxOS).

Appiumは、シミュレータ(iOS、FirefoxOS)、エミュレータ(Android)、およびリアルデバイス(iOS、Android、Windows、FirefoxOS)でテストされた、ネイティブ、ハイブリッド、モバイルのWebアプリケーション用のオープンソースのクロスプラットフォームテスト自動化ツールです。

公式サイト抜粋

使用環境

ソフトウェア バージョン
OS macOS Sierra 10.12.4
Xcode 8.3.2
Appium 1.6.4

環境構築

公式サイトのチュートリアルにそって進めていきます。

事前準備として予めテスト用のディレクトリを任意の場所に作成し作成したディレクトリに移動します。

ここでは /Users/username/以下にtestというディレクトリを作成しました。(usernameは各々のユーザ名)

上記で作成したディレクトリに移動。

$ cd /Users/username/test

1.2については私の環境ではすでに導入済みだったため、ここでは割愛します(またXcode8以降が既に導入済みという前提で進めていきます)。公式サイトのチュートリアル install Ruby以下に導入方法が載っています。

1. Ruby環境の構築

2. Homebrewをインストール

3.appium_consoleをインストール

$ gem uninstall -aIx appium_lib
$ gem uninstall -aIx appium_console
$ gem install --no-rdoc --no-ri appium_console

4.flakyをインストール

$ gem uninstall -aIx flaky
$ gem install --no-rdoc --no-ri flaky

5. nodeをインストール

$ brew install node

正しくインストールされているか確認します。

$ node --version 
v7.10.0

$ npm --version
4.2.0

6.antをインストール

公式サイトより最新のバージョンを確認し、antをインストールします。(ここではバージョン1.10.1)

$ curl http://ftp.riken.jp/net/apache//ant/binaries/apache-ant-1.10.1-bin.tar.gz -o apache-ant-1.10.1.tar.gz

ダウンロードしたファイルを展開します。

$ tar zxvf apache-ant-1.10.1.tar.gz

任意の場所にパッケージを配置します。

$ mv apache-ant-1.10.0 /usr/local/bin/

antのコマンドが実行できるよう、パスを通します。viで.bash_profileを開きます。

$ vi ~/.bash_profile

ファイル内に下記の設定を追記します。

ANT_HOME=/usr/local/bin/apache-ant-1.10.1
PATH=$ANT_HOME/bin:$PATH

変更を保存し、下記のコマンドを実行して設定内容を即時反映させます。

$ source ~/.bash_profile

正しくインストールされているか確認します。

$ ant -version
Apache Ant(TM) version 1.10.1 compiled on February 2 2017

7.mavenをインストール

Homebrew の brew search コマンドで、インストール可能な Maven の名前を確認します。

$ brew search maven

ここでは Maven 3.1 をインストールするので、homebrew/versions/maven31 を指定してインストールします。

$ brew install homebrew/versions/maven31

正しくインストールされているか確認します

$ mvn –version
Apache Maven 3.5.0 (ff8f5e7444045639af65f6095c62210b5713f426; 2017-04-04T04:39:06+09:00)
Maven home: /usr/local/Cellar/maven/3.5.0/libexec
Java version: 1.8.0_60, vendor: Oracle Corporation
Java home: /Library/Java/JavaVirtualMachines/jdk1.8.0_60.jdk/Contents/Home/jre
Default locale: ja_JP, platform encoding: UTF-8
OS name: "mac os x", version: "10.12.4", arch: "x86_64", family: "mac"

8.Appiumをインストール

Appiumをクローンします。

$ git clone git://github.com/appium/appium.git

クローンしたappiumディレクトリに移動します。

$ cd appium

下記のコマンドを実行します。

$ npm install

9.AppiumからiOS Simulatorの使用を許可する

$ npm install -g authorize-ios
$ authorize-ios

appiumを起動

$ node .

appium停止方法(appiumを起動させたターミナルのタブ以外で下記を実行)

$ killall -9 node

Appium Ruby Consoleを使ってみる

1.sample-appsを作成します。

$ npm install sample-apps

2.ios-uicatalogの作成

$ cd node_modules/sample-apps
$ npm i 

3.サンプルiOSアプリUICatalogをビルド

ios-uicatalogに移動

$ cd node_modules/ios-uicatalog

iphonesimulatorのバージョンの確認

$ xcodebuild -showsdks

iOS SDKs:
    iOS 10.3                        -sdk iphoneos10.3

iOS Simulator SDKs:
    Simulator - iOS 10.3            -sdk iphonesimulator10.3

macOS SDKs:
    macOS 10.12                     -sdk macosx10.12

tvOS SDKs:
    tvOS 10.2                       -sdk appletvos10.2

tvOS Simulator SDKs:
    Simulator - tvOS 10.2           -sdk appletvsimulator10.2

watchOS SDKs:
    watchOS 3.2                     -sdk watchos3.2

watchOS Simulator SDKs:
    Simulator - watchOS 3.2         -sdk watchsimulator3.2

ビルド

$ xcodebuild -configuration Release -sdk iphonesimulator10.3

3.コンソールの起動

appiumサーバーが起動していることを確認しサーバーが開いているタブとは別タブで下記のコマンドを実行。

$ arc

コンソールの起動とともにシミュレーターが起動しiOSシミュレーターが立ち上がります。

画面の要素のリストを出力

[1] pry(main)> page

他コマンドは公式サイトチュートリアルに記載されています。

4.コンソールの終了

[2] pry(main)> x
3
3
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
3
3