seleniumWebブラウザ上で自動でテストをさせるテストツールです。商用ではMercury QuickTest Professionalとかあります。よくできたツールなんですが、高い.. 環境http://www.openqa.org/selenium/より Selenium Core (selenium-core-0.8.2.zip) Selenium RC (selenium-remote-control-0.9.0.zip) Selenium IDE (Selenium IDE 0.8.7) をダウンロードします(2007/09/07)。このうちSelenium IDEはFireFox?のプラグインです。
Selenium IDEよりインストールします。インストール後、FireFox?の表示>サイドバーを選択すると、Selenium IDEが表示されていますので、
選択します。するとサイドバーに表示されますので、赤く丸いボタンで記録してくれます。自動で記録してくれます。これだけでもまず試してみましょう。
これで記憶できましたら、その操作ログがコマンドで記録されています。 java -jar selenium-server.jar で実行しておきます。TestSuite?とかのファイルがある場合は、以下のように java %PROXY_OPTION% -jar selenium-server.jar -htmlSuite "*ieplore" "http://www.testsitaiurl.com" "testsuite.html" "TestResult.html" -timeout 60000 ここで%PROXY_OPTION%は -Dhttp.proxyHost=hoge.proxy.com -Dhttp.proxyPort=8080 とか指定します。もしくは以下のサンプルでもあるようにSeleniumServer?のstartをつかっても起動できます。 今回はSelenium IDEで記録したデータをEclipse上からJunitを使って動かします。ではEclipseを実行し、Javaのプロジェクトを作成します。 このとき、ライブラリにselenium-remote-control-0.9.0\serverにある selenium-server.jar selenium-server-tests.jar とselenium-remote-control-0.9.0\javaにある selenium-java-client-driver.jar selenium-java-client-driver-tests.jar を追加しておきます。ではSelenium IDEのファイル>テストをエクスポート>Java Selenium RCを選んでソースを開けてコピペしたのが 以下のソースです。yahooでhogeで検索して、検索後の画面でhogeがあるかを検証しています。 package com.example.tests; import com.thoughtworks.selenium.SeleneseTestCase; public class Test extends SeleneseTestCase { private SeleniumServer seleniumServer; public void setUp() throws Exception { seleniumServer = new SeleniumServer(); seleniumServer.start(); super.setUp("http://www.yahoo.co.jp"); } public void tearDown() throws Exception { super.tearDown(); seleniumServer.stop(); } public void testTest() throws Exception { selenium.open("/"); selenium.type("fp", "hoge"); selenium.click("st"); // selenium.waitForPageToLoad("30000"); verifyTrue(selenium.isTextPresent("hoge")); } } ではJUnitでテストすると見事に緑色になってくれました。ちょっとよくわからないのが、 selenium.waitForPageToLoad?("30000");をコメントにしているのですが、はずすと com.thoughtworks.selenium.SeleniumException: 書き込みできません。 at com.thoughtworks.selenium.HttpCommandProcessor.doCommand(HttpCommandProcessor.java:73) となってしまいました。なんでだろ?googleではうまくいってるんですが。 リンクこれはすごい! Web案件必須 Selenium - 人気急上昇中自動テストツール第14回 Selenium IDEを使ってみました画像を使ってわかりやすい説明があります。 ここはSelenium HPの日本語訳ページです。本家のページを日本語訳されています。ありがたい。 第2回:Seleniumを体感する第4回まであります。 Selenium 0.7利用手順書(前編)あと Selenium 0.7利用手順書(後編),Selenium 0.7 TipsとExcelによるDB初期化もあります。 [selenium]Selenium RCのページSelenium RCとPHPUnit3.0とのサンプルがあります。 SeleniumRC ClientDriverでリモートサーバのDB初期化Seleniumでスクリーンショットスクリーンショットを取る拡張法が書かれています。 [Selenium]Selenium の新しいコマンドを作る同じメッセージが複数回出力される場合の拡張方法があります。 Selenium AES入門Auto Exec Serverか。 参考書籍WEB+DB PRESS Vol36 seleniumについての解説があります。 コメント
|