This chapter provides a complete listing and reference for the methods in the Basic OpenScript Application Programming Interface (API).
The following section provides an alphabetical listing of the methods in the Basic OpenScript API.
The following table lists the OpenScript Basic API methods in alphabetical order.
Table 3-1 List of EnterpriseOneService Methods
Method | Description |
---|---|
Immediately aborts the VUser as soon as possible. |
|
Specifies the begining of a new Step Group withor without delay timing. |
|
Calls functions from remote encrypted scripts that are not attached as script assets. |
|
Call a function in the current script. |
|
Calls functions from remote scripts that are not attached as script assets. |
|
Decrypts a string previously encrypted with the Base-64 Crypt algorithm. |
|
Delays the current VUser for the specified number of milliseconds. |
|
Deobfuscates a string previously obfuscated with the Base-64 Crypt algorithm. |
|
Encrypts a string with the Base-64 Crypt algorithm. |
|
Ends the Step Group that was most recently started using |
|
Transforms a string of data, substituting the values of variables where applicable. |
|
Allows the user to call a |
|
Defines the |
|
Service containing controller information. |
|
Service for reporting numeric counter values to a controller. |
|
Gets the Databank defined by the specified alias. |
|
Service containing iteration information. |
|
Gets and sets iteration results in a script. |
|
Helper method to find the AbstractScriptException in latest run Result. |
|
Helper method to find the latest run Result. |
|
Service for logging debug messages to a log file. |
|
Gets a child script that can run from this script or a public function defined in the child script can be called. |
|
Gets script package information. |
|
Gets session information. |
|
Gets the script settings. |
|
Gets and set step results. |
|
Gets the total number of completed iterations. |
|
Gets variables for this virtual user. |
|
Checks whether last run Result has exception. |
|
Writes a comment message to the console/log file, and to the Result View. |
|
Defines the |
|
Obfuscate a string with the Base-64 Crypt algorithm. |
|
Writes a failure message to the console/log file, and to the Result View. |
|
Writes a passed message to the console/log file, and to the Result View. |
|
Resume the script after abort. |
|
Defines the |
|
Find and run the specified script. |
|
Sets the script Error Recovery settings. |
|
Helper method to set the last run Result. |
|
Notify the controller that the virtual user has reached the specified synchronization point. |
|
Inserts "think time" delay into the script. |
|
Helper method to parse a String as a boolean. |
|
Helper method to parse a String as a Date. |
|
Helper method to parse a String as a signed decimal double in base 10. |
|
Helper method to parse a String as a signed decimal integer in base 10. |
|
Helper method to convert a list of arguments into a |
|
Helper method to parse a String as a signed decimal long in base 10. |
|
Helper method to convert a list of arguments into a |
|
Writes a warning message to the console/log file, and to the Result View |
The following sections provide detailed reference information for each method in the OpenScript Basic Application Programming Interface.
Immediately aborts the VUser as soon as possible. The remaining actions in the iteration, including any parent scripts and functions, will not complete.
The finish()
section will not be run. The currently running script will return a failed result indicating that the VUser was aborted.
If a VUser is aborted, it is possible to resume the script by catching the abort user exception and calling resume()
.
Abort a script at any point.
info("Running a script...");
abort()
info("This line will not be run.");
Abort and then resume.
try {
info("Perform any steps inside a try-catch block...");
abort()
info("This line will not be run.");
} catch (StopScriptRuntimeException e) {
// optionally take any corrective action and optionally resume script
resume();
}
Specifies the begining of a new Step Group withor without delay timing. Steps Groups may be used to group sequences of actions together and to report timing information.
beginStep()
must always be closed with endStep()
.
The beginStep method has the following command format:
beginStep(stepName);
beginStep(stepName, delayMs);
a String specifying the name used to identify this step, similar to a page title.
an Integer specifying the amount of time to wait in milliseconds before beginning the step. The delayMs value will be adjusted based on the VUser's current delay settings.
represents an exception that may be thrown during the execution of a script where the exception should be reported to an end user through the controller.
This API enables the invoking of functions from remote encrypted scripts that are not attached as script assets as long as the remote script is stored within a user defined script repository location.
The callEncryptedFunctionByPath method has the following command format:
callEncryptedFunctionByPath(repository, scriptPathRelToRepository, scriptPassword, functionName, args);
a String specifying the name of the user defined repository mapping where the remote script is stored. Must not be null
.
a String specifying the path to the script within the named repository. Any leading file separator on the path, such as / or \, is ignored. Must not be null
.
a String specifying the password of the specified script. May be null
if the script is not encrypted.
a String specifying the name of the function to call within the specified script. Must not be null
.
an Object specifying an optional list of arguments to pass to the called function. All String arguments will be evaluated before sending to the function.
Optional result of function call. If function is void
, then the result will be null
. User should cast return result to correct return object type. Thus if function returns int
or Integer
, then result should be cast to Integer
.
Example of calling function with API that is defined in same repository without any sub level directories.
public void run() throws Exception
{
beginStep("Call Remote Function Example");
{
callEncryptedFunctionByPath("Default", "myRemoteScript", "myEncryptionKey", "calculateTax", (Object[])null);
}
endStep();
}
Example of calling function with API that is defined in different repository with 'n' sub level directories.
public void run() throws Exception
{
beginStep("Call Remote Function Example");
{
callEncryptedFunctionByPath("ProductionScripts", "ApplicationOne/Finance/English/myRemoteScript", "myEncryptionKey", "calculateTax", (Object[])null);
}
endStep();
}
Example of calling function with API that is defined in the same repository with a return type of String.
public void run() throws Exception
{
beginStep("Call Remote Function Example");
{
String taxCalculationOutcome = (String)callEncryptedFunctionByPath("ProductionScripts", "ApplicationOne/Finance/English/myRemoteScript", "myEncryptionKey", "calculateTax", (Object[])null);
info("Result of Tax calculation: "+taxCalculationOutcome);
}
endStep();
}
Call a function in the current script.
a String specifying the name of function to call. Must not be null
.
an Object specifying an optional list of arguments to pass to the called function. All String arguments will be evaluated before sending to the function.
Optional result of function call. If function is void
, then the result will be null
. User should cast return result to proper class. Thus if function returns int
or Integer
, then result should be cast to Integer
. If function returns boolean
or Boolean, then result should be cast to Boolean.
This API enables the invoking of functions from remote scripts that are not attached as script assets as long as the remote script is stored within a user defined script repository location.
The callFunctionByPath method has the following command format:
callFunctionByPath(repository, scriptPathRelToRepository, functionName, args);
a String specifying the name of the user defined repository mapping where the remote script is stored. Must not be null
.
a String specifying the path to the script within the named repository. Any leading file separator on the path, such as / or \, is ignored. Must not be null
.
a String specifying the name of the function to call within the specified script. Must not be null
.
an Object specifying an optional list of arguments to pass to the called function. All String arguments will be evaluated before sending to the function.
Optional result of function call. If function is void
, then the result will be null
. User should cast return result to correct return object type. Thus if function returns int
or Integer
, then result should be cast to Integer
.
Example of calling function with API that is defined in same repository without any sub level directories.
public void run() throws Exception
{
beginStep("Call Remote Function Example");
{
callFunctionByPath("Default", "myRemoteScript", "calculateTax", (Object[])null);
}
endStep();
}
Example of calling function with API that is defined in different repository with 'n' sub level directories.
public void run() throws Exception
{
beginStep("Call Remote Function Example");
{
callFunctionByPath("ProductionScripts", "ApplicationOne/Finance/English/myRemoteScript", "calculateTax", (Object[])null);
}
endStep();
}
Example of calling function with API that is defined in the same repository with a return type of String.
public void run() throws Exception
{
beginStep("Call Remote Function Example");
{
String taxCalculationOutcome = (String)callEncryptedFunctionByPath("ProductionScripts", "ApplicationOne/Finance/English/myRemoteScript", "calculateTax", (Object[])null);
info("Result of Tax calculation: "+taxCalculationOutcome);
}
endStep();
}
Decrypts a string previously encrypted with the Base-64 Crypt algorithm.
represents an exception that may be thrown during the execution of a script where the exception should be reported to an end user through the controller.
if no password is specified for the encryption service.
Delays the current VUser for the specified number of milliseconds.
This method does NOT honor the VU Pacing settings defined in playback preferences. If the VUser is stopped for any reason (for example, if the Stop button is pressed), the VUser will be awakened immediately.
The VUser's status will be updated to reflect the fact that it is sleeping.
an Integer specifying the number of milliseconds to delay the VUser.
if no password is specified for the encryption service.
Encrypts a string with the Base-64 Crypt algorithm.
represents an exception that may be thrown during the execution of a script where the exception should be reported to an end user through the controller.
if no password is specified for the encryption service.
Ends the Step Group that was most recently started using beginStep()
.
a String specifying the name of step that was previously started using beginStep(stepName)
.
represents an exception that may be thrown during the execution of a script where the exception should be reported to an end user through the controller.
Transforms a string of data, substituting the values of variables where applicable.
The Transforms class provides utility functions for performing variable substitution inside strings containing custom transform syntax notation.
Many scripting languages support the ability to easily embed variable values inside strings. For example:
Ruby:
varDay = "Monday" puts "Today is #{varDay}."
Perl:
$varDay = "Monday" print "Today is $varDay."
The above examples would print "Today is Monday." to the standard output. In Java, the user has to type a more wordy expression to solve the above example:
String varDay = "Monday"; System.out.println("Today is " + varDay + ".");
OpenScript scripts provide an API to reference script variables using a special string format consisting of double-curly braces {{ }}, dubbed "custom transform syntax". Here is an example:
getVariables().set("varDay", "Monday"); getLogger().info("Today is {{varDay}}");
This class providers helper methods to substitute a collection of named variables and functions into a transform-syntax-formatted string. Transform syntax may contain zero or more variable or function references embedded inside double-curly brace characters.
Example:
"X is {{varX}} and Y is {{varY}}"
Indexed variable values may be referenced directly in the transform syntax by specifying the variable name and its 0-based indexed value inside brackets [ ]. The 0-based indexed value is returned if no index is specified.
Example:
"X is {{varX}} and {{varX[0]}}. X[1] is {{varX[1]}}."
Nested curly brace expressions are supported, and are evaluated from the inner-most expression to the outer-most expression.
Example:
"X[varIndex] is {{varX[{{varIndex}}]}}."
Function references are denoted by an @ sign preceding the function ID. Arguments are separated by commas. Literal commas inside arguments are escaped using two comma characters. See also: CustomFunction.
Example:
"Current timestamp is {{@timestamp()}}.
Variable and function references may be annotated with the variable's recorded value by appending a comma and the recorded value after the variable or function reference name.
Example:
"X is {{varX,123}}.
Literal {{ and/or }} sequences inside a string should be escaped with a # character prefix. Any literal # characters inside a string containing escaped {{ or }} sequences should be doubled.
Example (without transform syntax):
"Today is Monday. Other characters: {{}}!@#$%"
Example (with transform syntax):
"Today is {{varDay}}. Other characters: #{{#}}!@##$%"
represents an exception that may be thrown during the execution of a script where the exception should be reported to an end user through the controller.
Allows the user to call a fail(String)
operation in the script.
When this operation is called it stops execution of the script and displays the error string as a new step in results log.
Aborts the script playback by throwing a UserCausedFailureException
.
represents an exception that may be thrown during the execution of a script where the exception should be reported to an end user through the controller.
when the fail(String)
is invoked.
Defines the finish()
section of a script. The finish()
section is automatically added to the script code when you create a script project in OpenScript.
Add any cleanup code or perform any operations after all iterations are performed for this virtual user.
on any exception. On error, scripts should throw AbstractScriptException
instead of Exception whenever possible to provide more detail.
Service for reporting numeric counter values to a controller.
Check how timeres are treated and report counters to load controller.
boolean isPageTimer = getCounters().isTreatPageAsTimers(); if(isPageTimer){ info("treat page as timer"); } else{ info("do not treat page as timer"); } boolean isResTimer = getCounters().isTreatResourcesAsTimers(); if(isResTimer{ info("treat resource as timer"); } else{ info("do not treat resource as timer"); } boolean isTestTimer = getCounters().isTreatTestsAsTimers(); if(isTestTimer){ info("treat test as timer"); } else{ info("do not treat test as timer"); } getCounters().report("scriptName", "timerName", "timerId", "myCounter", AggType.Average, 10.0); getCounters().report("scriptName", "timerName", "timerId", "myNextcounter", 10.0, 0, 10); getCounters().setSessionName("mySessionName");
Gets and sets iteration results in a script.
Use in the Finish
section of the script.
Gets and sets iteration results in a script.
public void finish() throws Exception { //Iterations completed int totalComp = getTotalIterationsCompleted(); String competedIterations = String.valueOf(totalComp); info("Total Completed Iterations = " + competedIterations); //Comments and Warnings getIterationResult().addComment("iteration result comment"); getIterationResult().addWarning("iteration result warning"); String sCommentString = getIterationResult().getCommentString(); info("Comment String : " + sCommentString); String sWarningString = getIterationResult().getWarningsString(); info("Warining String: " + sWarningString); //Data Used 1 getIterationResult().addDataUsed("add data used1"); getIterationResult().addDataUsed("add data used2"); String dataUsedString = getIterationResult().getDataUsed(); info("Data used String: " + dataUsedString); //Data Used 2 ArrayList<String> dataUsed = new ArrayList<String>(); dataUsed.add("Data used 1"); dataUsed.add("Data used 2"); dataUsed.add("Data used 3"); getIterationResult().setDataUsed(dataUsed); info("Data Used" + dataUsed); //Get and Set Error (Sets Script failure) getIterationResult().setError("error string"); String getErrorString = getIterationResult().getErrorString(); info("Error String: " + getErrorString); getIterationResult().getError();// check for exception boolean isScriptPassed = getIterationResult().isPassed(); if(isScriptPassed){ info("script passed"); } else{ info("script not passed"); } //Start and Finish time long lFinishTime = getIterationResult().getFinishTime(); String sFinishTime = String.valueOf(lFinishTime); info("Finish time: " + sFinishTime); String outcome = getIterationResult().getOutcome(); info("Outcome: " + outcome); long lStartTime = getIterationResult().getStartTime(); String sStartTime = String.valueOf(lStartTime); info("Start time: " + sStartTime); getIterationResult().setFinishTime(lFinishTime); getIterationResult().setStartTime(lStartTime); //Step Name String sStepName = getIterationResult().getStepName(); info("Step Name: " + sStepName); getIterationResult().setStepName("stepName"); }
Helper method to find the AbstractScriptException in latest run Result.
Gets the last error. Use String.valueOf
instead of toString()
to prevent throwing a NullPointerException if the value returned is null
.
//Correct - String.valueOf(...); info(String.valueOf(getLastError()); //Incorrect - if null is returned will result in NullPointerException info(getLastError().toString());
Helper method to find the latest run Result.
Gets the last result.
AttachedData attachedData = getLastResult().getAttachedData(); info("Response Time: " + attachedData.get(ResultDeclaration.responseTime)); String summary = getLastResult().getSummary(); info("Summary = " + summary); Long dur = getLastResult().getDuration(); info("duration = " + dur); if (getLastResult().isFailed()) { info("Failed"); }
Gets the script settings.
The error recovery settings use IDs specific to the script type as follows:
Basic Script Settings:
getSettings().getErrorRecovery(
BasicErrorRecovery
.
setting
));
Utilities Settings:
getSettings().getErrorRecovery(
UtilitiesErrorRecovery
.
setting
));
Functional Test Module Script Settings:
getSettings().getErrorRecovery(
FTErrorRecovery
.
setting
));
Web Functional Module Script Settings:
getSettings().getErrorRecovery(
WebErrorRecovery
.
setting
));
Oracle EBS/Forms Functional Module Script Settings:
getSettings().getErrorRecovery(
FormsErrorRecovery
.
setting
));
Http Load Module Script Settings:
getSettings().getErrorRecovery(
HttpErrorRecovery
.
setting
));
Adobe Flex (AMF) Load Module Script Settings:
getSettings().getErrorRecovery(
AmfErrorRecovery
.
setting
));
Oracle EBS/Forms Load Module Script Settings:
getSettings().getErrorRecovery(
NcaErrorRecovery
.
setting
));
Gets the script settings and prints the value to the Results view.
VUserSettings VUSettings = getSettings();
info("Delay Between Iterations: " + VUSettings.getDelayBetweenIterations());
info("Delay Between Steps: " + VUSettings.getDelayBetweenSteps(0));
info("Encryption Properties File: " + VUSettings.getEncryptionPropertiesFile());
info("Machine Unique Number: " + VUSettings.getMachineUniqueNumber());
info("Max Save Cont Size: " + VUSettings.getMaxSaveContSize());
info("Port Number Maximum: " + VUSettings.getPortNumberMaximum());
info("Port Number Minimum: " + VUSettings.getPortNumberMinimum());
info("Replace URLs: " + VUSettings.getReplaceURLs());
info("Report Sender Interval: " + VUSettings.getReportSenderInterval());
info("Result Report Folder: " + VUSettings.getResultReportFolder());
info("Is On Error Stop VU: " + VUSettings.getIsOnErrorStopVU());
info("Is Using Databank: " + VUSettings.getIsUsingDatabank());
info("Report Counters: " + VUSettings.getReportCounters());
info("Use Recorded Value: " + VUSettings.getUseRecordedValue());
info("VU Logging Options: " + VUSettings.getVULoggingOptions());
info("is Execute User Defined Tests: " + VUSettings.isExecuteUserDefinedTests());
info("is No Report: " + VUSettings.isNoReport());
info("set Date Format: M/d/yy" );
VUSettings.setDateFormat("M/d/yy");
info("set Is Using Databank: false" );
VUSettings.setIsUsingDatabank(false);
info("File not found error setting: " +
VUSettings.getErrorRecovery(BasicErrorRecovery.ERR_FILE_NOT_FOUND));
Gets and set step results.
Use in Step Groups in the Run
section of the script
Gets and sets step results in a script.
//Comments and Warnings getStepResult().addComment("step result comment"); getStepResult().addWarning("step result warning"); String sCommentString = getStepResult().getCommentString(); info("Comment String : " + sCommentString); String sWarningString = getStepResult().getWarningsString(); info("Warining String: " + sWarningString); //Data Used 1 getStepResult().addDataUsed("add data used1"); getStepResult().addDataUsed("add data used2"); String dataUsedString = getStepResult().getDataUsed(); info("Data used String: " + dataUsedString); //Data Used 2 ArrayList<String> dataUsed = new ArrayList<String>(); dataUsed.add("Data used 1"); dataUsed.add("Data used 2"); dataUsed.add("Data used 3"); getStepResult().setDataUsed(dataUsed); info("Data Used" + dataUsed); //Get and Set Error (Sets Step failure) getStepResult().setError("error string"); String getErrorString = getStepResult().getErrorString(); info("Error String: " + getErrorString); getStepResult().getError();// check for exception boolean isStepPassed = getStepResult().isPassed(); if(isStepPassed){ info("step passed"); } else{ info("step not passed"); } //Start and Finish time long lFinishTime = getStepResult().getFinishTime(); String sFinishTime = String.valueOf(lFinishTime); info("Finish time: " + sFinishTime); String outcome = getStepResult().getOutcome(); info("Outcome: " + outcome); long lStartTime = getStepResult().getStartTime(); String sStartTime = String.valueOf(lStartTime); info("Start time: " + sStartTime); getStepResult().setFinishTime(lFinishTime); getStepResult().setStartTime(lStartTime); //Step Name String sStepName = getStepResult().getStepName(); info("Step Name: " + sStepName); getStepResult().setStepName("stepName");
Gets the total number of completed iterations.
The getTotalIterationsCompleted method has the following command format:
getTotalIterationsCompleted();
Get the total number of completed iterations and prints the value to the Results view.
public void finish() throws Exception {
int totalComp = getTotalIterationsCompleted();
String completedIterations = String.valueOf(totalComp);
info("Total Completed Iterations = " + completedIterations);
}
Gets variables for this virtual user. Variables persist for the lifetime of the virtual user.
Examples of using getVariables()
to get and set script variables.
getVariables().set("myTodayVar", "{{@today(MM/dd/yyyy)}}", Variables.Scope.LOCAL); getVariables().set("timestamp", "{{@timestamp}}", Variables.Scope.GLOBAL); String myToday = getVariables().get("myTodayVar"); String myTime = getVariables().get("timestamp"); info(myToday); info(myTime); Variables variables = new Variables(); variables.set("myvarname", "myVarValue"); variables.set("myvarname1", "myVarValue1"); getVariables().addVariables(variables); info(getVariables().get("myvarname")); info(getVariables().get("myvarname1")); String[] myVarArray = { "now", "then", "later" }; getVariables().setAll("myVarArray", myVarArray, Scope.LOCAL); getVariables().getAll("myVarArray"); info("{{myVarArray[0]}}"); info("{{myVarArray[1]}}"); info("{{myVarArray[2]}}"); String[] allLocalVarNames = getVariables().getAllVariableNames(Scope.LOCAL); for (int i = 0; i < allLocalVarNames.length; i++) info("local var name: " + allLocalVarNames[i]); String[] myGlobalVarArray = { "US", "Europe", "Asia" }; getVariables().setAll("myGlobalVarArray", myGlobalVarArray, Scope.GLOBAL); info("{{myGlobalVarArray[0]}}"); info("{{myGlobalVarArray[1]}}"); info("{{myGlobalVarArray[2]}}"); String[] allGlobalVarNames = getVariables().getAllVariableNames(Scope.GLOBAL); for (int i = 0; i < allGlobalVarNames.length; i++) info("global var name: " + allGlobalVarNames[i]); String[] allVarNames = getVariables().getAllVariableNames(); for (int i = 0; i < allVarNames.length; i++) info("var name: " + allVarNames[i]); getVariables().clearVariables();
Writes a comment message to the console/log file, and to the Result View.
This method will never alter the flow of a script, such as stopping the script. Any variables specified in message
will be evaluated to their current values.
If a variable expression is specified in message
that does not exist, or if message
cannot be evaluated for any reason:
1. A warning-level message will be printed to the console/log file indicating why the message could not be evaluated.
2. The original message, not evaluated, will be printed to the console/log file.
3. The Results View comment field will contain the original message, plus a warning note explaining why the message could not be evaluated.
4. Any problems that occur when evaluating the message will not be counted as a warning in the results report warnings total.
5. The execution of the script will continue as if no problem occurred.
a String specifying the message to write to the console/log file and Results view. May contain embedded function and variable expressions using the Transforms syntax. Must NOT be null
.
represents an exception that may be thrown during the execution of a script where the exception should be reported to an end user through the controller.
Get the total number of completed iterations and prints the value to the Results view.
public void finish() throws Exception {
int totalComp = getTotalIterationsCompleted();
String completedIterations = String.valueOf(totalComp);
info("Total Completed Iterations = " + completedIterations);
}
Defines the initialize()
section of a script. The initialize()
section is automatically added to the script code when you create a script project in OpenScript.
Add code to be executed once before any iterations are run for this virtual user.
on any exception. On error, scripts should throw AbstractScriptException
instead of Exception whenever possible to provide more detail.
Obfuscate a string with the Base-64 Crypt algorithm.
a String specifying the name used to identify this step, similar to a page title.
represents an exception that may be thrown during the execution of a script where the exception should be reported to an end user through the controller.
Writes a failure message to the console/log file, and to the Result View.
This method will never alter the flow of a script, such as stopping the script. Any variables specified in message
will be evaluated to their current values.
If a variable expression is specified in message
that does not exist, or if message
cannot be evaluated for any reason:
1. A warning-level message will be printed to the console/log file indicating why the message could not be evaluated.
2. The original message, not evaluated, will be printed to the console/log file.
3. The Results View comment field will contain the original message, plus a warning note explaining why the message could not be evaluated.
4. Any problems that occur when evaluating the message will not be counted as a warning in the results report warnings total.
5. The execution of the script will continue as if no problem occurred.
a String specifying the message to write to the console/log file and Results view. May contain embedded function and variable expressions using the Transforms syntax. Must NOT be null
.
represents an exception that may be thrown during the execution of a script where the exception should be reported to an end user through the controller.
Writes a passed message to the console/log file, and to the Result View.
This method will never alter the flow of a script, such as stopping the script. Any variables specified in message
will be evaluated to their current values.
If a variable expression is specified in message
that does not exist, or if message
cannot be evaluated for any reason:
1. A warning-level message will be printed to the console/log file indicating why the message could not be evaluated.
2. The original message, not evaluated, will be printed to the console/log file.
3. The Results View comment field will contain the original message, plus a warning note explaining why the message could not be evaluated.
4. Any problems that occur when evaluating the message will not be counted as a warning in the results report warnings total.
5. The execution of the script will continue as if no problem occurred.
a String specifying the message to write to the console/log file and Results view. May contain embedded function and variable expressions using the Transforms syntax. Must NOT be null
.
represents an exception that may be thrown during the execution of a script where the exception should be reported to an end user through the controller.
Defines the run()
section of a script. The run()
section is automatically added to the script code when you create a script project in OpenScript.
Add code to be executed during each iteration for this virtual user.
on any exception. On error, scripts should throw AbstractScriptException
instead of Exception whenever possible to provide more detail.
Find and run an encrypted script given the script's name, workspace, repository and its password.
If the script cannot be found on the local machine using the given repository, this method will ask this script's controller to find the script on its machine.
In order to run this script, iterationCount
must be greater or equal to 1
.
The script's initialize
and finish
sections will be executed exactly once. The initialize
section will be executed first; the finish
section will be executed last; the run
section may be executed at most iterationCount
times between the initialize
and finish
sections.
If there is an error in the initialize
section, the run
section will not be executed.
If the playback error handling preference "On iteration failure, do not run more iterations" is true
and there is an error thrown during the run
section, the remaining iterations will not be executed.
If there is an error during child script execution, the "Child Script Failed" error recovery setting will recover the error according to its setting.
The runScript method has the following command format:
runScript(repository, scriptPathRelToRepository, iterationCount);
runScript(repository, scriptPathRelToRepository, iterationCount, scriptPassword);
a String specifying the name of the repository where the script is stored. For example, "Repository1"
.
a String specifying the path to the script within the named repository. Any leading file separator on the path, such as / or \, is ignored. Must not be null
. Legacy repository structures required a trailing "!" character at the end of folder names.
an integer that defines how many times this script's run section should run. If iterationCount
is less than 1, then the script will not run at all.
a String specifying the password of the script. May be null
if the script is not encrypted.
represents an exception that may be thrown during the execution of a script where the exception should be reported to an end user through the controller.
Sets the script Error Recovery settings.
The error recovery action can be set to the following:
.Fail .Ignore .Pause .ReportErrorAndContinue .Warn
The error recovery settings IDs are specific to the script type as follows:
Basic Script Settings
setErrorRecovery(BasicErrorRecovery.setting, ErrorRecoveryAction.setting);
Utilities Settings
setErrorRecovery(UtilitiesErrorRecovery.setting, ErrorRecoveryAction.setting);
Functional Test Module Script Settings
setErrorRecovery(FTErrorRecovery.setting, ErrorRecoveryAction.setting);
Web Functional Module Script Settings
setErrorRecovery(WebErrorRecovery.setting, ErrorRecoveryAction.setting);
Oracle EBS/Forms Functional Module Script Settings
setErrorRecovery(FormsErrorRecovery.setting, ErrorRecoveryAction.setting);
Http Load Module Script Settings
setErrorRecovery(HttpErrorRecovery.setting, ErrorRecoveryAction.setting);
Adobe Flex (AMF) Load Module Script Settings
setErrorRecovery(AmfErrorRecovery.setting, ErrorRecoveryAction.setting);
Oracle EBS/Forms Load Module Script Settings
setErrorRecovery(NcaErrorRecovery.setting, ErrorRecoveryAction.setting);
an ErrorRecoveryId enum specifying the error recovery type.
an ErrorRecoveryAction enum specifying the error recovery action.
Helper method to set the last run Result.
How to build Result object for http.verifyText() API.
import oracle.oats.scripting.modules.functionalTest.api.exceptions.MatchException;
import oracle.oats.scripting.modules.basic.api.IResult.ResultCode;
//[...]
AttachedData data = new AttachedData();
data.set(ResultDeclaration.verifyText_expected, "expected text");
data.set(ResultDeclaration.verifyText_actual, "actual text");
long duration = 1000;
MatchException matchException = new MatchException("Text match test failed", null,
false);
IResult result = new Result(ResultCode.FAIL, duration, matchException, data,
matchException.getLocalizedMessage());
setLastResult(result);
Notify the controller that the virtual user has reached the specified synchronization point.
The virtual user will wait until the controller responds indicating that it is OK to proceed. The controller defines when it is OK to proceed; for example, continue running only after 80% of virtual users have reached the synchronization point.
When running from within OpenScript, the synchronization point will be released immediately; the virtual user will not wait.
This method will update the last result object with details of the synchronization point operation, including how long the operation took.
a String specifing the unique synchronization point name upon which to notify and wait, as defined in the controller.
represents an exception that may be thrown during the execution of a script where the exception should be reported to an end user through the controller.
Inserts "think time" delay into the script.
This method honors the VU Pacing settings defined in playback preferences. Invoke this method to sleep the current VUser for a given number of seconds. If the VUser is stopped for any reason (for example, if the Stop button is pressed), the VUser will be awakened immediately.
The VUser's status will be updated to reflect the fact that it is "thinking."
a String specifing the unique synchronization point name upon which to notify and wait, as defined in the controller.
represents an exception that may be thrown during the execution of a script where the exception should be reported to an end user through the controller.
Writes a warning message to the console/log file, and to the Result View.
This method will never alter the flow of a script, such as stopping the script. Any variables specified in message
will be evaluated to their current values.
If a variable expression is specified in message
that does not exist, or if message
cannot be evaluated for any reason:
1. A warning-level message will be printed to the console/log file indicating why the message could not be evaluated.
2. The original message, not evaluated, will be printed to the console/log file.
3. The Results View comment field will contain the original message, plus a warning note explaining why the message could not be evaluated.
4. Any problems that occur when evaluating the message will not be counted as a warning in the results report warnings total.
5. The execution of the script will continue as if no problem occurred.
a String specifying the message to write to the console/log file and Results view. May contain embedded function and variable expressions using the Transforms syntax. Must NOT be null
.
represents an exception that may be thrown during the execution of a script where the exception should be reported to an end user through the controller.