7
9

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

はじめてのSelenium IDE ~自動化したものをスケジューラで回す~

Last updated at Posted at 2015-12-11

やりたいこと

Selenium IDEで自動操作ができるようになったので、これを周期的に実行したい!

要件としては以下の通り
-できるだけ短期間で簡単に!
-インストールはあまりしたくない!
-コーディングはしたくない!Eclipsとか嫌!
-せっかく自動化なので、手動とかないわー

実現方法の検討

色々と調べてみたら大きく以下の2つ(間違ってたら指摘を・・・・)
①Selenium RC
②Selenium WebDriver

上記の②はどう調べてもコーディングが必要で、おまけに何かしらの言語を動かすセットアップが必要となるようです。
お客様が厳しいのでセットアップは嫌だー

と、いうことで①で攻めることに

準備

Selenium RCというやつを実行するにはSelenium Serverが必要なようです。
また、Selenium IDEでひと手順必要なようです。

Selenium Serverのインストール

インストールと言ってもただのファイルダウンロードです!
①Seleiumのサイトを開く
http://www.seleniumhq.org/

②「Download Selenium」をクリック
image

③「Selenium Standalone Server」のバージョン部分をクリック
image

④ファイルを保存
適当な場所に保存してください。私は「c:\selenium」というフォルダを作って保存しました。
image

Selenium IDEでの準備作業

テストスイートとかいうやつが必要になります。

①予めテストケースを開いておきます。
image

②「ファイル」→「テストスイートに名前を付けて保存」と選択します。
image

③保存します。
image

※例としてテストスイートのファイルと自動化HTMLを「c:\selenium」に置きます

~中身がどうなっているのか~
こんな感じで自動化HTMLを呼んでいます。
image

実行

実行は以下のコマンドとなります。
java -jar SeleniumServerのjarファイルパス -htmlsuite "*firefox" アプリケーションのURL テストスイートのファイルパス 結果HTMLのパス

例ではこうなります
java -jar C:\selenium\selenium-server-standalone-2.48.2.jar -htmlsuite "*firefox" http://www.google.co.jp C:\selenium\OK_Google_Suite.html C:\selenium\result.html

image

画面が上がってくるので待ちます。自動的に動いてくれます。
image

以上です。バッチ化してタスクスケジューラなどで動かすのも良しです。

※どうにも落ちるので、googleからYahoo検索する自動化HTMLをつくりました。
image

うまくいかないときメモ

・テストスイートと自動化HTMLは同一フォルダ内に配置すること
・証明書エラーで次に進めない場合は「-trustAllSSLCertificates」オプションを付けること

7
9
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
7
9

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?