Selenium Gridで遊ぼう

Post on 21-Jul-2015

264 views 3 download

Transcript of Selenium Gridで遊ぼう

Selenium Gridで遊ぼう

東平洋史

自己紹介• 名前東平洋史(とうへいひろふみ)

• 職業ある会社のテスト技術者

• Selenium使用歴2014/3/4(月)~

• 前歴NTT 武蔵野通研→NTTコミュニケーションズ→某社→CTCシステムオペレーションズ→株式会社SHIFT

Seleniumとは?

• 原子番号34の元素

• 元素記号はSe

• 第16族元素–酸素と同族

–ハロゲンの隣

• 灰色セレン–金属セレン

–六方晶系

–融点は217.4℃

• 赤色セレン

–単斜晶系

ではなくて

Seleniumとは?

http://docs.seleniumhq.org/

• Webベースアプリケーション用テスト自動化ツール

• ライセンスはApache 2.0 License

今回御紹介するのは

Selenium Gridhttps://github.com/SeleniumHQ/selenium/wiki/Grid2

•複数のマシンで並列実行

•複数の環境を集中管理

↓テストのコスト最小化

その構造

Selenium Grid Server (Hub)

テストスクリプト

Grid (node) Grid (node)

Internet ExplorerMozilla FirefoxGoogle Chrome

Safari

Windows Mac

Grid (node) Grid (node)

Safari Google Chrome

iPhone Android

Web Application

その構造

Selenium Grid Server (Hub)

テストスクリプト

Grid (node) Grid (node)

Internet ExplorerMozilla FirefoxGoogle Chrome

Safari

Windows Mac

Grid (node) Grid (node)

Safari Google Chrome

iPhone Android

Web Application

その構造

Selenium Grid Server (Hub)

テストスクリプト

Grid (node) Grid (node)

Internet ExplorerMozilla FirefoxGoogle Chrome

Safari

Windows Mac

Grid (node) Grid (node)

Safari Google Chrome

iPhone Android

Web Application

その構造

Selenium Grid Server (Hub)

テストスクリプト

Grid (node) Grid (node)

Internet ExplorerMozilla FirefoxGoogle Chrome

Safari

Windows Mac

Grid (node) Grid (node)

Safari Google Chrome

iPhone Android

Web Application

その構造

Selenium Grid Server (Hub)

テストスクリプト

Grid (node) Grid (node)

Internet ExplorerMozilla FirefoxGoogle Chrome

Safari

Windows Mac

Grid (node) Grid (node)

Safari Google Chrome

iPhone Android

Web Application

実行に必要なもの(1)

• Seleniuem Grid Server用

–JRE(Java Runtime Environment)

–Selenium Serverhttp://www.seleniumhq.org/download/

実行に必要なもの(2)

• Selenium Grid Node用–JRE

–Selenium Server

–Webブラウザ起動用http://www.seleniumhq.org/download/

•ChromeDriver

• The Internet Explorer Driver Server

など

Selenium Grid使用手順

1. Selenium Grid Serverを立てる

2. Selenium Grid Nodeを追加する

3. テストスクリプトから呼び出す

Selenium Grid Serverを立てる

• 次のコマンドを実行java –jar selenium-server-standalone–role hub(例)java -jar C:¥Selenium¥bin¥SeleniumServer¥selenium-server-standalone-2.45.0.jar -role hub

Selenium Grid Nodeを追加する(1)

• 設定用JSONファイルを書く{“capabilities”:

[ {“platform”: プラットフォーム,“browserName”: ブラウザ名,“maxInstances”: 起動するインスタンスの最大数,“version”: バージョン番号,“seleniumProtocol”: “WebDriver“},…

],

”configuration”:{“hub”: “http://サーバ名:4444/grid/register"}

}

ブラウザ分作成

Selenium Gridサーバの指定

Selenium Grid Nodeを追加する(2)

• 次のコマンドを実行java –jar selenium-server-standalone-role node -nodeConfig設定用JSONファイル-Dwebdriver.chrome.driver=ChromeDriver-Dwebdriver.ie.driver=IEDriverServer

• この部分は適宜変更

テストスクリプトから呼び出す(1)

1. DesiredCapabilitiesクラスのインスタンス生成

2. インスタンスの属性設定

3. RemoteWebDriverクラスを使用してWebDriver生成

テストスクリプトから呼び出す(2)

(例) Firefoxを呼び出す場合DesiredCapabilities capability =

DesiredCapabilities.firefox();

capability.setVersion("26.0");

WebDriver driver =new RemoteWebDriver(new

URL("http://192.168.2.10:4444/wd/hub"), capability);

ここで実習

実習内容

次のテストを行なうスクリプトの作成

1. Googleで「小江戸らぐ」を検索

2. 次のページを表示OSS支える!コミュニティー訪問~小江戸らぐ-川越を中心にゆるく活動するLinuxユーザー会

3. 写真をクリックして拡大表示

まとめ

Selenium Grid

•複数のマシンで並列実行

•複数の環境を集中管理

↓テストのコスト最小化