メインコンテンツまでスキップ
バージョン:23.5

AskとAnswerを使用してテスト方法を組み合わせる

テストは常に完全に自動化されたものや完全に手動のタスクではありません。多くの条件下では、2つのアプローチを組み合わせることが、アプリケーションを適切にテストするための最も効率的または合理的な方法であるかもしれません。Eggplant Functionalは、テスターがテストの実行中に自動テストの詳細を手動で指定することを可能にするいくつかの有用なコマンドを含んでいます。

AskAnswerのコマンド群は、アプリケーションまたはテストの要件が合理的に自動化するには複雑すぎる場合、テスターがテスト入力やブランチング動作についての決定をオンデマンドで行うことを可能にします。コマンドはEggplant Functionalまたはオペレーティングシステム内のダイアログボックスを生成し、テスターが適切なタイミングで決定を下すよう促します。

これらのコマンドは、テスターの決定をテストにフィードバックするためにit変数を活用します。

答え

Answerコマンドは、テスターが事前に定義されたオプションから選択できるプロンプトを生成します。Answerは、テスターがテスト対象のアプリケーションの複雑なインターフェースが適切に描画または動作しているかどうかを慎重に判断する必要がある場合、またはテスターがブランチングシナリオでテストがどの方向を追うかについて動的に制御したい場合に有用です。

例:

Answer "検索結果のフォーマットは正しいですか?" with "はい" or "いいえ" title "結果フォーマットの確認" timeout 60 seconds

上記のAnswerコマンドは、タイムアウトが60秒の次のプロンプトダイアログを作成します:

AnswerDialog.png

上記のプロンプトへの応答 - はい、いいえ、または空白 - は変数"it"に返されます:

If it is "Yes"
LogSuccess "The formatting is correct!"
else if it is "No"
LogError "The formatting is not correct. The test has failed."
Answer "Which recovery scenario should be run?" with "Application Restart" or "Page Refresh" title "Recovery Scenario Selection"
if it is "Application Restart"
ApplicationRestart
else if it is "Page Refresh"
PageRefresh
end if
else if it is empty -- If the Answer window times out, it is returned empty
LogWarning "The formatting check timed out before a human could check the formatting. Capturing a screenshot for later review!"
CaptureScreen
end if
to ApplicationRestart
Click "Menu"
Click "Exit"
DoubleClick "ApplicationIcon"
end ApplicationRestart
to PageRefresh
Click "Menu"
Click "Refresh"
end PageRefresh

リストから選択する

Answerコマンドは、リストセレクタを返すこともできます。以下の構文:

put ["home", "work", "Account", "login"] into myListOfChoices
answer "Account" from list the unique items of myListOfChoices

これを返します:

Eggplant Functional Answer コマンドによって返されるリストセレクター

質問する

Askコマンドは、テスターが選択した文字列を提供できるフィールドでテスターをプロンプトします。このコマンドは、カスタムログメッセージやパスワードをテストに入力するのに役立ちます。

例:

Ask "What is the username?"
Put it into UserName
Ask Password "What is the password?"
// Ask Password is a special variety of Ask that hides the string when it is typed into the prompt field
Put it into Password

AskPasswordDialog.png

Click "UserNameField"
TypeText UserName
Click "PasswordField"
Set the scriptlogging to Silent
-- Setting scriptlogging to Silent prevents the password from appearing in the log file with the TypeText command
TypeText Password
Set the scriptlogging to On
Log "The password was typed!"

Ask File/Folder と Answer File/Folder

Ask file/folderとAnswer file/folderは、入力用のファイルを選択したり、出力を保存する場所を選択したりするために、オペレーティングシステムのローカルファイルエクスプローラを利用します。

Answer file of type "txt", ".csv" in folder "C:\Users\Carrie\Desktop"
put it into myFileContents
// このAnswer fileコマンドは、指定されたファイル拡張子を持つファイルのみを表示します

AskFileDialog.png

Ask file of type ".txt" in folder "C:\Users\Carrie\Desktop\Results"
put it into myResultsFile
repeat with each line myLine of file myFileContents
Click "SearchField"
TypeText myLine
Put "I am searching for" && myLine & period & CRLF after file myResultsFile
end repeat
end repeat

特別な注意点

これらのプロンプトは、スクリプトがGUIモードから実行された場合にのみ生成され、コマンドラインからは生成されないため、実行マシン上にEggplant Functional開発ライセンスが利用可能である必要があります。

追加情報

it変数AskとAnswer、およびAsk file/folderとAnswer file/folderに関するさらなる文書もあります。