Script and API Calling
Use the following SenseTalk commands in Eggplant Functional to call other scripts or API tests.
Run
Command
Behavior: Calls another script as if the script were a command. If an error or exception occurs within the called script, the calling script will fail as well. If there is an uncaught exception in the called script, execution will stop.
Parameters: One script name and any parameters values that the called script can receive.
Syntax:
Run scriptName
Example:
Run "Logout Procedure" //Calls a script named "Logout Procedure"
Example:
Run "Login", "SusanG76", "password123!@#" // Calls a script named "Login" with parameter values "SusanG76" and "password123!@#"
Read more about the run command in the SenseTalk Reference documentation.
If the other script is located in the same suite as the current script (or an associated helper suite), and its name begins with a letter and contains only letters, digits, and underscores, you can call it as a command in the current script. (You do not have to use the Run
command, just the name of the script you are calling, followed by any parameters.)
Example:
Login "SusanG76", "password123!@#"
If the script you are calling has a return, you can capture the return using the result
.
Example:
Run "ValidateOutput" // Calls a script named "ValidateOutput" with contents 'return "Test passed!"'
put the result into FormOutput // Stores the string "Test passed!" in a variable
RunFeature
Command
Behavior: This command calls a Gherkin Feature (.feature file) as if the Feature were a command. This command lets you trigger Features from SenseTalk scripts. When the Feature executes, it generates its own results file, similarly to running a script with RunWithNewResults
.
Parameters: One Feature name (required); optionally, you can include any number of tags. Use a tilde (~) in front of a tag to exclude it rather than include it.
If running Gherkin Features from the command line, any parameters passed in the command line call (including tests executed via Eggplant Manager) will take precedence over tags passed as parameters in a SenseTalk script.
Syntax:
RunFeature featureName, "@tag1,@orTag2 @andTag3", "@andTag4"
You can include multiple tags within one set of quotes. Tags separated by a comma follow OR logic. Tags separated by a space follow AND logic. If both OR and AND conditions exist, the OR always takes precedence and is evaluated first. Joining a parameter within a separate set of quotes forces an AND condition.
Example:
RunFeature FeatureTest1
Example:
RunFeature "FeatureTest1", "@important,@regression" // Runs FeatureTest1 but only elements within it that include either the @important tag or the @regression tag
Example:
RunFeature "FeatureTest1", "@important ~@regression" // Runs FeatureTest1 but only elements within it that include the @important tag and don't include the @regression tag
Example:
RunFeature "AccountingApp" "@over,@rcvd" "@billing" // The elements from AccountingApp that run need to have the @billing tag and either the @over tag or the @rcvd tag
Related:
RunWithNewResults
Command or Function
Behavior: Runs another script that generates its own results log, as opposed to scripts called with the Run
command, which are logged as part of the calling script. The RunWithNewResults
command returns a results property list similar to the ScriptResults
function. For more information, see ScriptResults
Function and the Results Properties. If the called script fails, the calling script does not automatically fail or raise an exception. You can script this behavior based on the returned Status property from the results property list.
Parameters: One script name, and any parameters it requires to run.
Syntax:
RunWithNewResults scriptNameAs a function:
RunWithNewResults( scriptName )
Returns: A results property list. For more information, see ScriptResults
Function.
Example:
RunWithNewResults "Logout" // Calls a script named "Logout" and creates a separate set of results for it
Example:
RunWithNewResults "Login", "SusanG76", "password123!@#" // Calls a script named "Login" with parameter values "SusanG76" and "password123!@#" and creates a separate set of results for it