Skip to main content

Using Ask and Answer to Combine Testing Methods

Testing is not always an entirely automated or entirely manual task. Under many conditions, combining the two approaches might be the most efficient or reasonable way to properly test an application. Eggplant Functional includes several useful commands that allow a tester to manually direct the specifics of an automated test during test execution.

The Ask and Answer family of commands allow the tester to make decisions about test inputs and branching behavior on demand, when the requirements of the application or test are too complex to be reasonably automated. The commands generate dialog boxes in Eggplant Functional or in the operating system to prompt the tester to make the decisions at the appropriate times.

These commands leverage the it variable in order to feed the tester’s decision back into the test.


The Answer command generates a prompt that allows the tester to choose from a set of pre-defined options. Answer is useful when the tester must make a careful decision about whether a complex interface in the application under test is rendering or behaving properly, or when the tester wants dynamic control over which direction the test follows in a branching scenario.


Answer "Does the format of the search results look correct?" with "Yes" or "No" title "Verify Results Formatting" timeout 60 seconds

The Answer command above creates the following prompt dialog, with a timeout of 60 seconds:


The response to the above prompt—yes, no, or empty—is returned in the variable "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"
else if it is "Page Refresh"
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!"
end if
to ApplicationRestart
Click "Menu"
Click "Exit"
DoubleClick "ApplicationIcon"
end ApplicationRestart
to PageRefresh
Click "Menu"
Click "Refresh"
end PageRefresh

Selecting from a List

The Answer command also can return a list selector. The following syntax:

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

returns this:

A list selector returned by the Eggplant Functional Answer command


The Ask command prompts the tester with a field in which they can provide the string of their choice. This command can be helpful for inputting custom log messages or passwords into a test.


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


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 and Answer File/Folder

Ask file/folder and Answer file/folder use the operating system’s local file explorer to aid in selecting files for input, or locations to save output.

Answer file of type "txt", ".csv" in folder "C:\Users\Carrie\Desktop"
put it into myFileContents
// This Answer file command displays only the files with the specified file extensions


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

Special Considerations

These prompts are generated only when the script is executed from GUI mode, and not from the command line, so an Eggplant Functional Development license must be available on the execution machine.

Additional Information

We also have further documentation regarding the it variable, Ask and Answer, and Ask file/folder and Answer file/folder.