【入門】Geb+SpockではじめるWebテスト~クロスブラウザテスト編~ / Setting up and running of the cross-browser test
【入門】Geb+SpockではじめるWebテスト~クロスブラウザテスト編~ / Setting up and running of the cross-browser test
著者:ふじさわゆうき
Author: Yuki Fujisawa
この記事は、以下の記事の続きです。/ This article is a continuation of the following article.
初めて訪問した方は以下の記事を参照してください。 / First person who visited, please see the following article.
目次 / Table of contents
- 前回までのあらすじ / Overview of up to the previous article
- 今回の目的 / The goal of this article
- ChromeによるWebテスト / Web testing with Chrome
- IEによるWebテスト / Web testing with IE
- FireFoxによるWebテスト / Web testing with FireFox
- まとめ
1. 前回までのあらすじ
- Gebとは何かの説明 / The description of what is Geb
- Gebのメリット説明 / Description of Geb benefits
- 「Eclipse + maven + Geb + Spock」での開発環境構築説明 / Development environment construction described with using "Geb + Spock"
- サンプルプログラム実装 / Sample program implementation
- google検索⇒検索結果⇒WIKIという流れのWebテスト実施 / Web test explanation that "google search ⇒ results ⇒WIKI"
- 「Geb + Spock」による上記Webテストの実施 / Implementation of the above Web test using the "Geb + Spock"
2. 今回の目的 / The purpose of this article
- クロスブラウザテストができるようになること / To get ability cross-browser testing with "Geb and Spock".
- 対象はChrome , InternetExplorer(IE) , FireFoxの3ブラウザ / Taget browser are Chrome , InternetExplorer(IE) and FireFox
3. ChromeによるWebテスト / Web testing with Chrome
- GoogleWikipediaTest Projectにdriverフォルダを作成します / You create a driver folder in GoogleWikipediaTest Project
- GoogleWikipediaTest/driver
- chromedriver_win32.zipを取得します / You get chromedriver_win32.zip
- chromedriver_win32.zipを解凍して、chromedriver.exeをdriverフォルダに置きます
- GoogleWikipediaTest/driver/chromedriver.exe
- GebConfig.groovyをGoogleWikipediaTest/src/main/resourcesに作成します / You create a GebConfig.groovy to GoogleWikipediaTest/src/main/resources
- GoogleWikipediaTest/src/main/resources/GebConfig.groovy
- GebConfig.groovyにChromeの設定を追記します / You append the Chrome settings GebConfig.groovy
//choose "htmlunit", "firefox", "ie", "chrome" driver = "chrome" //chrome - http://chromedriver.storage.googleapis.com/index.html System.setProperty("webdriver.chrome.driver", "driver/chromedriver.exe")
6. GoogleWikipediaMainTest.groovyを実行します / Run the GoogleWikipediaMainTest.groovy
7. Chromeが起動してテストが実行されればOKです / Chrome setting is the OK, if the test is up and running
4. IEによるWebテスト / Web testing with IE
- IEのセキュリティ設定を「保護モードを有効にする」で統一します / Unify the IE security settings in the "Enable Protected Mode"
- インターネットオプション > セキュリティ
- Internet Options > Security
- Get IEDriverServer_Win32_2.47.0.zip
- 解凍してIEDriverServer.exeをdriverフォルダに置きます / Unzip to place the IEDriverServer.exe to driver folder
- GoogleWikipediaTest/driver/IEDriverServer.exe
- GebConfig.groovyを修正します / Change the GebConfig.groovy
- driver = "ie"
- System.setProperty("webdriver.ie.driver", "driver/IEDriverServer.exe")
//choose "htmlunit", "firefox", "ie", "chrome" driver = "ie" //chrome - http://chromedriver.storage.googleapis.com/index.html System.setProperty("webdriver.chrome.driver", "driver/chromedriver.exe") //ie - http://selenium-release.storage.googleapis.com/index.html System.setProperty("webdriver.ie.driver", "driver/IEDriverServer.exe")
6. GoogleWikipediaMainTest.groovyを実行します / Run the GoogleWikipediaMainTest.groovy
7. IEが起動してテストが実行されればOKです / IE setting is OK, if the test is up and running
5. FireFoxによるWebテスト / Web testing with FireFox
- GebConfig.groovyを修正します/ Change the GebConfig.groovy
- driver = "firefox"
//choose "htmlunit", "firefox", "ie", "chrome" driver = "firefox" //chrome - http://chromedriver.storage.googleapis.com/index.html System.setProperty("webdriver.chrome.driver", "driver/chromedriver.exe") //ie - http://selenium-release.storage.googleapis.com/index.html System.setProperty("webdriver.ie.driver", "driver/IEDriverServer.exe")
2. GoogleWikipediaMainTest.groovyを実行します / Run the GoogleWikipediaMainTest.groovy
3. firefoxが起動してテストが実行されればOKです / firefox setting is OK, if the test is up and running
6. まとめ / Summary
- driverフォルダにIEとChromeのライブラリを追加する / Add the IE and Chrome's library to driver folder
- GebConfig.groovyに設定を追記する / Append the setting to GebConfig.groovy
- driver
- System.setProperty("webdriver.chrome.driver", "driver/chromedriver.exe")
- System.setProperty("webdriver.ie.driver", "driver/IEDriverServer.exe")
- "driver=***"に「"chrome", "ie", "firefox"」のいずれかを設定することでクロスブラウザテストができる / Cross-browser tests can by setting to "driver = ***", " chrome " or " ie " or " firefox "
- (ex)driver = "chrome"
参考文献 / Bibliography
- GebConfig
- Chome
- IE