LoginSignup
13
15

More than 5 years have passed since last update.

Selenium IDEで作ったテストを実行できるgrunt-seleniumについて紹介するよ

Last updated at Posted at 2013-12-07

grunt-seleniumとは

FirefoxのAdd-onのSelenium IDEで作ったテストケース、テストスイートを実行できるGruntプラグインです。内部ではWebDriver Wire Protocolを利用

Selenium IDEの問題点

SeleniumIDEは画面上でデバッグできる反面、Firefox上でしか実行できないのが残念です。
WebDriverのプログラムコードへのエクスポート機能を利用すれば、他のブラウザで実行できますが、
エクスポート時に対応していないコマンドが多数あったり、、、

WebDriver Playbackの登場によって他のブラウザでの実行が解決されましたが、
gruntからPlaybackを実行できる方法がわからなかったので、gruntからテストケースのHTMLをパースし、wb(node.js)で実行という方法をとりました。

grunt-seleniumで何ができるか

  • SeleniumIDEで作成した複数のテストスイートを一括実行できる
  • SeleniumIDEのコマンドをWebDriverで実行できる(WebDriverに足りていない機能を補完)
  • Firefox以外のブラウザでも実行できる
  • 実行結果をTAP形式で出力できる

Install

npm install --save-dev grunt-selenium

Grunfileのサンプル

module.exports = function(grunt) {

  // Project configuration.
  grunt.initConfig({

    // Configuration to be run (and then tested).
    selenium: {
      options: {
        startURL : 'http://sideroad.secret.jp/',
        browsers: ['firefox', 'chrome', 'phantomjs'],
        log: 'test/wd.log'
      },
      main: {
        files: {
         'test/main.tap': ['test/*.suite']
        }
      }
    },
    clean: ['test/main.tap']
  });

  grunt.loadNpmTasks('grunt-contrib-clean');
  grunt.loadNpmTasks('grunt-selenium');

  // By default, lint and run all tests.
  grunt.registerTask('default', ['clean', 'selenium']);
};
13
15
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
13
15