<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
		xmlns:xhtml="http://www.w3.org/1999/xhtml"
>

<channel>
	<title>イージーネット Tech Blog &#187; Selenium</title>
	<atom:link href="http://blog.eni.co.jp/tech/category/test/selenium/feed" rel="self" type="application/rss+xml" />
	<link>http://blog.eni.co.jp/tech</link>
	<description>株式会社イージーネットのスタッフによる技術系ブログです</description>
	<lastBuildDate>Tue, 12 Jan 2010 01:46:58 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.6</generator>
	<language>ja</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<xhtml:link rel="alternate" media="handheld" type="text/html" href="http://blog.eni.co.jp/tech/category/test/selenium/feed" />
		<item>
		<title>SeleniumRCで自己署名証明書使用のWEBアプリケーションをテストする際、セキュリティ警告を表示させない方法</title>
		<link>http://blog.eni.co.jp/tech/2009/07/selenium_firefox_self_signed_ssl.html</link>
		<comments>http://blog.eni.co.jp/tech/2009/07/selenium_firefox_self_signed_ssl.html#comments</comments>
		<pubDate>Thu, 23 Jul 2009 01:33:58 +0000</pubDate>
		<dc:creator>笹山 昭秀</dc:creator>
				<category><![CDATA[Java]]></category>
		<category><![CDATA[Selenium]]></category>
		<category><![CDATA[テスト]]></category>
		<category><![CDATA[Firefox]]></category>
		<category><![CDATA[Profile]]></category>
		<category><![CDATA[自動テスト]]></category>
		<category><![CDATA[自己署名証明書]]></category>

		<guid isPermaLink="false">http://blog.eni.co.jp/tech/?p=901</guid>
		<description><![CDATA[こんにちは。プロダクト&#38;サービス事業部の笹山です。
前回のブログ(Seleniumの自動テストを止めることなく、Flexを手動操作する方法)で「FlashSeleniumについて調査をして、このブログに公開できたら・・・」などと書きましたが、全く調査できておりません。お詫び申し上げます。
前回のブログ執筆時後、SeleniumRCのバージョンも1.0.1に上がっていますし、FlashSeleniumもSeleniumRC1.0互換のものが出ているようです。
ですから、現時点では「あっさり動いてしまう？」のかもしれません。
今回もSeleniumRCネタではありますが「SeleniumRCで自己署名証明書使用のWEBアプリケーションをテストする際、Firefoxからのセキュリティ警告を表示させない方法」について書きたいと思います。

自己署名証明書使用のWEBアプリケーションをテストする際の問題
SSL対応のWEBアプリケーションのテストを行う際に、自己署名証明書を作成してテストすることは多いと思います。
SeleniumRCで自己署名証明書使用のWEBアプリケーションのテストを行うことはもちろん可能です。
しかし、面倒くさい操作が発生してしまうのです。
サーバに接続する際に、「信頼できない接続 &#8211; 接続の安全性を確認できません」と警告が出ます。
例外として追加しても毎回警告が表示され、そのたびに例外に追加する操作を行わなければいけません。
これでは、SeleniumRCを用いての自動テストの意味がありません。
問題の解決方法
これを解決する方法が分かりました。ただしFirefoxでのみです。
FirefoxでSeleniumServer用のProfileを作成し、SeleniumServer起動時にそのProfileを指定させれば良いのです。
それでは、まず最初にFirefoxでSeleniumServer用のProfileを作成する手順について説明します。
SeleniumServer用のProfile作成手順

アクセサリ-ファイル名を指定して実行でFirefoxのProfileManagerを起動します
firefox.exe -ProfileManager

「新しいプロファイルを作成」でSelenium用のプロファイルを作成します

プロファイル作成ウィザードで順番に作成していきます
※安全のため保存先は、Selenium用のフォルダを作成し、そのフォルダを指定することをお勧めします

Selenium用のプロファイル作成後、作成したプロファイルを指定して自己署名証明書使用のサイトにアクセスします
「信頼できない接続 &#8211; 接続の安全性を確認できません」と警告が出ます

自己署名証明書使用のサイトを例外として追加し、セキュリティ例外を承認します


後にも先にも、Firefoxで自己署名証明書使用のサイトを例外として追加する操作はこの1回だけです。
次に、SeleniumServerへProfileを指定する方法を説明します。
JUnitテストソースでSeleniumServer起動時にProfileを指定させるコード
使用するProfileを指定して、SeleniumServerを起動するコードです。

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
// 自己署名証明書使用のURL
testUrl = &#34;https://localhost:8443&#34;;
&#160;
// テストを行うブラウザ
testBrowser = &#34;*firefox&#34;;
&#160;
// SeleniumServerのインスタンス化
seleniumServer = new SeleniumServer&#40;&#41;;
&#160;
// Selenium用プロファイルの指定 --------- ここから -------------
RemoteControlConfiguration config = seleniumServer.getConfiguration&#40;&#41;;
config.setFirefoxProfileTemplate&#40;new File&#40;&#34;D:\\firefox_selenium&#34;&#41;&#41;;
// Selenium用プロファイルの指定 --------- ここまで -------------
&#160;
// SeleniumServerの起動
seleniumServer.start&#40;&#41;;
&#160;
// seleniumClientを起動
selenium = new DefaultSelenium&#40;&#34;localhost&#34;, 4444, testBrowser, testUrl&#41;;
selenium.start&#40;&#41;;

selenium-server.jarファイル実行時にProfileを指定させる方法
上記のJUnitのテストケースではなく、別途SeleniumServerを起動してテストを行う場合は、以下のコマンドを実行してください。
java -jar selenium-server.jar -firefoxProfileTemplate d:\\selenium-firefox
最後に
これで通常通りSeleniumRCで自動テストを実行すると、わずらわしい警告は出なくなるはずです。
Firefoxのみの対処方法でしたが、IEやその他ブラウザでの解決方法はまだ分かっていません。
調査を続行していこうと思っています。（FlashSeleniumの調査も忘れずに！）
あわせて読みたい
Seleniumの自動テストを止めることなく、Flexを手動操作する方法
]]></description>
			<content:encoded><![CDATA[<p>こんにちは。プロダクト&amp;サービス事業部の笹山です。</p>
<p><a href="http://blog.eni.co.jp/tech/2009/05/selenium_wait.html">前回のブログ</a>(<a href="http://blog.eni.co.jp/tech/2009/05/selenium_wait.html">Seleniumの自動テストを止めることなく、Flexを手動操作する方法</a>)で「FlashSeleniumについて調査をして、このブログに公開できたら・・・」などと書きましたが、全く調査できておりません。お詫び申し上げます。</p>
<p><a href="http://blog.eni.co.jp/tech/2009/05/selenium_wait.html">前回のブログ</a>執筆時後、<a title="Selenium" href="http://seleniumhq.org/" target="_blank">SeleniumRC</a>のバージョンも1.0.1に上がっていますし、<a title="FlashSelenium" href="http://code.google.com/p/flash-selenium/downloads/list" target="_blank">FlashSelenium</a>もSeleniumRC1.0互換のものが出ているようです。<br />
ですから、現時点では「あっさり動いてしまう？」のかもしれません。</p>
<p>今回もSeleniumRCネタではありますが「SeleniumRCで自己署名証明書使用のWEBアプリケーションをテストする際、Firefoxからのセキュリティ警告を表示させない方法」について書きたいと思います。<br />
<span id="more-901"></span></p>
<h3>自己署名証明書使用のWEBアプリケーションをテストする際の問題</h3>
<p>SSL対応のWEBアプリケーションのテストを行う際に、自己署名証明書を作成してテストすることは多いと思います。</p>
<p>SeleniumRCで自己署名証明書使用のWEBアプリケーションのテストを行うことはもちろん可能です。<br />
しかし、面倒くさい操作が発生してしまうのです。</p>
<p>サーバに接続する際に、「信頼できない接続 &#8211; 接続の安全性を確認できません」と警告が出ます。<br />
<div id="attachment_895" class="wp-caption aligncenter" style="width: 310px"><a href="http://blog.eni.co.jp/tech/wp-content/uploads/2009/07/firefox_warn_ssl.png"><img src="http://blog.eni.co.jp/tech/wp-content/uploads/2009/07/firefox_warn_ssl-300x183.png" alt="警告 - 信頼できない接続" title="警告 - 信頼できない接続" width="300" height="183" class="size-medium wp-image-895" /></a><p class="wp-caption-text">警告 - 信頼できない接続</p></div></p>
<p>例外として追加しても毎回警告が表示され、そのたびに例外に追加する操作を行わなければいけません。<br />
これでは、SeleniumRCを用いての自動テストの意味がありません。</p>
<h3 class="caption">問題の解決方法</h3>
<p>これを解決する方法が分かりました。ただしFirefoxでのみです。<br />
FirefoxでSeleniumServer用のProfileを作成し、SeleniumServer起動時にそのProfileを指定させれば良いのです。</p>
<p>それでは、まず最初にFirefoxでSeleniumServer用のProfileを作成する手順について説明します。</p>
<h3>SeleniumServer用のProfile作成手順</h3>
<ol>
<li>アクセサリ-ファイル名を指定して実行でFirefoxのProfileManagerを起動します<br />
<div id="attachment_896" class="wp-caption aligncenter" style="width: 310px"><a href="http://blog.eni.co.jp/tech/wp-content/uploads/2009/07/exec_firefox_profilemanger.png"><img src="http://blog.eni.co.jp/tech/wp-content/uploads/2009/07/exec_firefox_profilemanger-300x178.png" alt="ファイル名を指定して実行 - ProfileManager" title="ファイル名を指定して実行 - ProfileManager" width="300" height="178" class="size-medium wp-image-896" /></a><p class="wp-caption-text">ファイル名を指定して実行 - ProfileManager</p></div></p>
<pre>firefox.exe -ProfileManager</pre>
</li>
<li>「新しいプロファイルを作成」でSelenium用のプロファイルを作成します<br />
<div id="attachment_897" class="wp-caption aligncenter" style="width: 310px"><a href="http://blog.eni.co.jp/tech/wp-content/uploads/2009/07/firefox_profilemanager_add_profile.png"><img src="http://blog.eni.co.jp/tech/wp-content/uploads/2009/07/firefox_profilemanager_add_profile-300x173.png" alt="新しいプロファイルを作成" title="新しいプロファイルを作成" width="300" height="173" class="size-medium wp-image-897" /></a><p class="wp-caption-text">新しいプロファイルを作成</p></div>
</li>
<li>プロファイル作成ウィザードで順番に作成していきます<br />
<span style="color: #ff0000;">※安全のため保存先は、Selenium用のフォルダを作成し、そのフォルダを指定することをお勧めします</span><br />
<div id="attachment_898" class="wp-caption aligncenter" style="width: 310px"><a href="http://blog.eni.co.jp/tech/wp-content/uploads/2009/07/firefox_profilemanager_wizard.png"><img src="http://blog.eni.co.jp/tech/wp-content/uploads/2009/07/firefox_profilemanager_wizard-300x226.png" alt="プロファイル作成ウィザード" title="プロファイル作成ウィザード" width="300" height="226" class="size-medium wp-image-898" /></a><p class="wp-caption-text">プロファイル作成ウィザード</p></div>
</li>
<li>Selenium用のプロファイル作成後、作成したプロファイルを指定して自己署名証明書使用のサイトにアクセスします<br />
「信頼できない接続 &#8211; 接続の安全性を確認できません」と警告が出ます<br />
<div id="attachment_895" class="wp-caption aligncenter" style="width: 310px"><a href="http://blog.eni.co.jp/tech/wp-content/uploads/2009/07/firefox_warn_ssl.png"><img src="http://blog.eni.co.jp/tech/wp-content/uploads/2009/07/firefox_warn_ssl-300x183.png" alt="警告 - 信頼できない接続" title="警告 - 信頼できない接続" width="300" height="183" class="size-medium wp-image-895" /></a><p class="wp-caption-text">警告 - 信頼できない接続</p></div>
</li>
<li>自己署名証明書使用のサイトを例外として追加し、セキュリティ例外を承認します<br />
<div id="attachment_900" class="wp-caption aligncenter" style="width: 310px"><a href="http://blog.eni.co.jp/tech/wp-content/uploads/2009/07/firefox_warn_exception_site.png"><img src="http://blog.eni.co.jp/tech/wp-content/uploads/2009/07/firefox_warn_exception_site-300x253.png" alt="例外として追加" title="例外として追加" width="300" height="253" class="size-medium wp-image-900" /></a><p class="wp-caption-text">例外として追加</p></div></p>
<p><div id="attachment_899" class="wp-caption aligncenter" style="width: 310px"><a href="http://blog.eni.co.jp/tech/wp-content/uploads/2009/07/firefox_add_exception_site.png"><img src="http://blog.eni.co.jp/tech/wp-content/uploads/2009/07/firefox_add_exception_site-300x300.png" alt="セキュリティ例外を承認" title="セキュリティ例外を承認" width="300" height="300" class="size-medium wp-image-899" /></a><p class="wp-caption-text">セキュリティ例外を承認</p></div>
</li>
</ol>
<p>後にも先にも、Firefoxで自己署名証明書使用のサイトを例外として追加する操作はこの1回だけです。</p>
<p>次に、SeleniumServerへProfileを指定する方法を説明します。</p>
<h3>JUnitテストソースでSeleniumServer起動時にProfileを指定させるコード</h3>
<p>使用するProfileを指定して、SeleniumServerを起動するコードです。</p>

<div class="wp_codebox"><table width="100%" ><tr id="p9012"><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
</pre></td><td class="code" id="p901code2"><pre class="java" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">// 自己署名証明書使用のURL</span>
testUrl <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;https://localhost:8443&quot;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">// テストを行うブラウザ</span>
testBrowser <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;*firefox&quot;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">// SeleniumServerのインスタンス化</span>
seleniumServer <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> SeleniumServer<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">// Selenium用プロファイルの指定 --------- ここから -------------</span>
RemoteControlConfiguration config <span style="color: #339933;">=</span> seleniumServer.<span style="color: #006633;">getConfiguration</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
config.<span style="color: #006633;">setFirefoxProfileTemplate</span><span style="color: #009900;">&#40;</span><span style="color: #000000; font-weight: bold;">new</span> <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Afile+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #003399;">File</span></a><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;D:<span style="color: #000099; font-weight: bold;">\\</span>firefox_selenium&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #666666; font-style: italic;">// Selenium用プロファイルの指定 --------- ここまで -------------</span>
&nbsp;
<span style="color: #666666; font-style: italic;">// SeleniumServerの起動</span>
seleniumServer.<span style="color: #006633;">start</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">// seleniumClientを起動</span>
selenium <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> DefaultSelenium<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;localhost&quot;</span>, 4444, testBrowser, testUrl<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
selenium.<span style="color: #006633;">start</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></td></tr></table></div>

<h3>selenium-server.jarファイル実行時にProfileを指定させる方法</h3>
<p>上記のJUnitのテストケースではなく、別途SeleniumServerを起動してテストを行う場合は、以下のコマンドを実行してください。</p>
<pre>java -jar selenium-server.jar -firefoxProfileTemplate d:\\selenium-firefox</pre>
<h3>最後に</h3>
<p>これで通常通りSeleniumRCで自動テストを実行すると、わずらわしい警告は出なくなるはずです。</p>
<p>Firefoxのみの対処方法でしたが、IEやその他ブラウザでの解決方法はまだ分かっていません。<br />
調査を続行していこうと思っています。（FlashSeleniumの調査も忘れずに！）</p>
<h3>あわせて読みたい</h3>
<p><a href="http://blog.eni.co.jp/tech/2009/05/selenium_wait.html">Seleniumの自動テストを止めることなく、Flexを手動操作する方法</a></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.eni.co.jp/tech/2009/07/selenium_firefox_self_signed_ssl.html/feed</wfw:commentRss>
		<slash:comments>2</slash:comments>
		<xhtml:link rel="alternate" media="handheld" type="text/html" href="http://blog.eni.co.jp/tech/2009/07/selenium_firefox_self_signed_ssl.html" />
	</item>
		<item>
		<title>Seleniumの自動テストを止めることなく、Flexを手動操作する方法</title>
		<link>http://blog.eni.co.jp/tech/2009/05/selenium_wait.html</link>
		<comments>http://blog.eni.co.jp/tech/2009/05/selenium_wait.html#comments</comments>
		<pubDate>Fri, 29 May 2009 08:17:50 +0000</pubDate>
		<dc:creator>笹山 昭秀</dc:creator>
				<category><![CDATA[Java]]></category>
		<category><![CDATA[Selenium]]></category>
		<category><![CDATA[テスト]]></category>
		<category><![CDATA[Flash]]></category>
		<category><![CDATA[Flex]]></category>
		<category><![CDATA[Wait]]></category>
		<category><![CDATA[自動テスト]]></category>

		<guid isPermaLink="false">http://blog.eni.co.jp/tech/?p=478</guid>
		<description><![CDATA[はじめまして。
プロダクト&#38;サービス事業部の笹山です。
今回は、SeleniumRCを用いてWebアプリケーションのテスト中に、Flex部分のみを手動操作し、
その後再び自動テストを継続させる方法について書きたいと思います。
有名なツールなのでみなさんご存知と思いますが、まずSeleniumRCとは、
「Webブラウザの操作を自動化させ、Webアプリケーションの画面表示や画面遷移のテストを行うツール」で
Webアプリケーションのテストには欠かせないツールです。
今回弊社では、easyFiLEXのテストをSeleniumRCを用いて行うことになりました。

easyFiLEXテストでSeleniumRCを使用する際の問題
弊社Tech Blog(05/18)記事にもあるように、easyFiLEXではFlexを採用しています。
easyFiLEXには、Wizard形式の画面があり、その一部画面にFlexが採用されています。
しかし、SeleniumRCは一般的なWebアプリケーションのテストを行うツールで、Flexには対応していません。
そのため、Flexが採用されているWizard形式の１画面がクリアできず、次の画面のテストができないのです。
ここをどう解決するか非常に悩みました。
FlashSelenium発見と挫折
まずは、Google先生に聞いてみました。
すると以下のサイトが検索に引っ掛かりました。

「Selenium RCによるFlash用の機能テストの作成と実行」

FlashSeleniumというSeleniumRCとFlexを連携させるツールです。
「これで解決！（Flex部分のテストも自動化できる！）」と思いました。
意気揚揚と公開されているサンプルを動かしはじめましたが、サンプルすら動きませんでした。（動いた方は教えてください。）

FlashSeleniumのサンプルFlash
FlashSeleniumのサンプルテストコード

解決方法の発見
途方に暮れselenium-client-driverのJavaDocを眺めていた時、ふと目に入った文字が・・・。
com.thoughtworks.selenium.Wait
便利なクラスがselenium-client-driverに用意されていました。
「条件がtrueになるまで、指定時間待つ」というものです。
easyFiLEXのテストでは以下の手順で使用しました。
手順内の画面は、
Flexが採用されているWizard形式の１画面で、「ファイルのアップロード後、送信先を指定する画面」です。
送信先を指定しない限り、次の画面へ進むことができないようになっています。

Flexが採用されている画面までは、SeleniumRCを用いてWizard形式画面の自動テストを行います。
Flexが採用されている画面に遷移後、SeleniumRCで送信先を指定せずに「次へ」ボタンを押下させ、バリデーションエラーを発生させます。
バリデーションエラー：「送信先が選択されていません。1つ以上選択してください。」
/li>
バリデーションエラーが画面上に表示されている間は、指定時間待機させます。（以下コード参照）
待機中にFlex操作を手動で行い、バリデーションエラーが画面上から消えると、再び自動テストが始まります。

Selenium実行途中でWaitをかけるコード

1
2
3
4
5
6
7
8
9
new Wait&#40;&#41; &#123;
    public boolean until&#40;&#41; &#123;
        if&#40;!selenium.isTextPresent&#40;&#34;送信先が選択されていません。1つ以上選択してください。&#34;&#41;&#41; &#123;
            return true;
        &#125; else &#123;
            [...]]]></description>
			<content:encoded><![CDATA[<p>はじめまして。</p>
<p>プロダクト&amp;サービス事業部の笹山です。</p>
<p>今回は、SeleniumRCを用いてWebアプリケーションのテスト中に、Flex部分のみを手動操作し、<br />
その後再び自動テストを継続させる方法について書きたいと思います。</p>
<p>有名なツールなのでみなさんご存知と思いますが、まずSeleniumRCとは、<br />
「Webブラウザの操作を自動化させ、Webアプリケーションの画面表示や画面遷移のテストを行うツール」で<br />
Webアプリケーションのテストには欠かせないツールです。</p>
<p>今回弊社では、<a title="easyFiLEX" href="http://www.eni.co.jp/products/easyfilex/index.html" target="_blank">easyFiLEX</a>のテストをSeleniumRCを用いて行うことになりました。<br />
<span id="more-478"></span></p>
<h3>easyFiLEXテストでSeleniumRCを使用する際の問題</h3>
<p><a title="Tech Blog（05/18）記事" href="http://blog.eni.co.jp/tech/2009/05/air_flex_draganddrop.html" target="_blank">弊社Tech Blog(05/18)記事</a>にもあるように、easyFiLEXではFlexを採用しています。<br />
easyFiLEXには、Wizard形式の画面があり、その一部画面にFlexが採用されています。</p>
<p>しかし、SeleniumRCは一般的なWebアプリケーションのテストを行うツールで、Flexには対応していません。<br />
そのため、Flexが採用されているWizard形式の１画面がクリアできず、次の画面のテストができないのです。</p>
<p>ここをどう解決するか非常に悩みました。</p>
<h3>FlashSelenium発見と挫折</h3>
<p>まずは、Google先生に聞いてみました。</p>
<p>すると以下のサイトが検索に引っ掛かりました。</p>
<ul>
<li><a title="http://www.adobe.com/jp/devnet/flash/articles/flash_selenium.html" href="「Selenium RCによるFlash用の機能テストの作成と実行」" target="_blank">「Selenium RCによるFlash用の機能テストの作成と実行」</a></li>
</ul>
<p>FlashSeleniumというSeleniumRCとFlexを連携させるツールです。</p>
<p>「これで解決！（Flex部分のテストも自動化できる！）」と思いました。<br />
意気揚揚と公開されているサンプルを動かしはじめましたが、サンプルすら動きませんでした。（動いた方は教えてください。）</p>
<ul>
<li><a title="FlashSeleniumのサンプルFlash" href="http://www.geocities.com/paulocaroli/flash/colors.html" target="_blank">FlashSeleniumのサンプルFlash</a></li>
<li><a title="FlashSeleniumのサンプルテストコード" href="http://code.google.com/p/flash-selenium/" target="_blank">FlashSeleniumのサンプルテストコード</a></li>
</ul>
<h3>解決方法の発見</h3>
<p>途方に暮れselenium-client-driverのJavaDocを眺めていた時、ふと目に入った文字が・・・。</p>
<pre><strong>com.thoughtworks.selenium.Wait</strong></pre>
<p>便利なクラスがselenium-client-driverに用意されていました。</p>
<p><strong>「条件がtrueになるまで、指定時間待つ」</strong>というものです。<br />
easyFiLEXのテストでは以下の手順で使用しました。</p>
<p>手順内の画面は、</p>
<pre>Flexが採用されているWizard形式の１画面で、「ファイルのアップロード後、送信先を指定する画面」です。
送信先を指定しない限り、次の画面へ進むことができないようになっています。</pre>
<ol>
<li>Flexが採用されている画面までは、SeleniumRCを用いてWizard形式画面の自動テストを行います。</li>
<li>Flexが採用されている画面に遷移後、SeleniumRCで送信先を指定せずに「次へ」ボタンを押下させ、バリデーションエラーを発生させます。<br />
バリデーションエラー：<span style="color: #ff0000;">「送信先が選択されていません。1つ以上選択してください。」</span></p>
<p><div id="attachment_505" class="wp-caption aligncenter" style="width: 291px"><a href="http://blog.eni.co.jp/tech/wp-content/uploads/2009/05/selenium_wait.png"><img class="size-medium wp-image-505" title="selenium_wait" src="http://blog.eni.co.jp/tech/wp-content/uploads/2009/05/selenium_wait-281x300.png" alt="easyFiLEX送信先設定画面におけるバリデーションエラー" width="281" height="300" /></a><p class="wp-caption-text">easyFiLEX送信先設定画面におけるバリデーションエラー発生時の画面</p></div></li>
<li>バリデーションエラーが画面上に表示されている間は、指定時間待機させます。（<a href="#wait_code">以下コード参照</a>）</li>
<li>待機中にFlex操作を手動で行い、バリデーションエラーが画面上から消えると、再び自動テストが始まります。</li>
</ol>
<h3 id="wait_code">Selenium実行途中でWaitをかけるコード</h3>

<div class="wp_codebox"><table width="100%" ><tr id="p4784"><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
</pre></td><td class="code" id="p478code4"><pre class="java" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">new</span> Wait<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000066; font-weight: bold;">boolean</span> until<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        <span style="color: #000000; font-weight: bold;">if</span><span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span>selenium.<span style="color: #006633;">isTextPresent</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;送信先が選択されていません。1つ以上選択してください。&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
            <span style="color: #000000; font-weight: bold;">return</span> <span style="color: #000066; font-weight: bold;">true</span><span style="color: #339933;">;</span>
        <span style="color: #009900;">&#125;</span> <span style="color: #000000; font-weight: bold;">else</span> <span style="color: #009900;">&#123;</span>
            <span style="color: #000000; font-weight: bold;">return</span> <span style="color: #000066; font-weight: bold;">false</span><span style="color: #339933;">;</span>
        <span style="color: #009900;">&#125;</span>
    <span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span>.<span style="color: #006633;">wait</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;タイムアウト&quot;</span>, 60000<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></td></tr></table></div>

<h3>最後に</h3>
<p>Flex部分だけは手動操作になってしまいますが、それ以降はスムーズに自動テストできるので現時点ではこの方法でテストを行っています。</p>
<p>時間の都合上、FlashSeleniumについて深く調査はしていませんが、調査をして「このブログに公開できたら・・・」と思っています。</p>
<h3>公式サイト</h3>
<ul>
<li><a title="Selenium公式サイト" href="http://seleniumhq.org/" target="_blank">Selenium公式サイト</a></li>
</ul>
<div id="FluJE_quick_lookup" style="opacity: 0;"><span>Quick Lookup:</span></p>
<input id="FluJE_quick_lookup_input" /></div>
<h3>あわせて読みたい</h3>
<p><a href="http://blog.eni.co.jp/tech/2009/07/selenium_firefox_self_signed_ssl.html">SeleniumRCで自己署名証明書使用のWEBアプリケーションをテストする際、セキュリティ警告を表示させない方法</a></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.eni.co.jp/tech/2009/05/selenium_wait.html/feed</wfw:commentRss>
		<slash:comments>2</slash:comments>
		<xhtml:link rel="alternate" media="handheld" type="text/html" href="http://blog.eni.co.jp/tech/2009/05/selenium_wait.html" />
	</item>
	</channel>
</rss>
