public class

MbtScriptExecutor

extends Object
java.lang.Object
   ↳ com.webmbt.plugin.MbtScriptExecutor

Class Overview

Provides system functions for MScript.

MScript functions are called in MScript using the following syntax:
$funcName('p1','p2', ...)

Notice the function name must be prefixed with "$".

All parameters must be quoted using single-quote as shown in the example above. Data type is automatically detected and converted if necessary.

MScript functions may or may not return a value.

Each MScript function may have multiple calling signatures with varying number of parameters.

MScript function can be nested called as shown in the example below:
$rand('$getData('ds1','col1')').

Besides system MScript functions, there are plugin MScript functions provided by each plugin that you have enabled for the model as well as MScript function provided by your own plugins and custom MScript functions. See more details at MScript Functions.

Copyright © 2008 - 2017 TestOptimal LLC. All Rights Reserved.

Summary

Public Methods
void Break(String label_p, String condition_p)
performs Break on the current mscript block when the condition specifed evaluates to true.
void Break(String label_p)
performs Break on the mscript block identified by the parameter
void Break()
performs Break on the current mscript tag, e.g.
void Continue(String label_p)
perform Continueon the while loop identified.
void Continue()
skip the rest of the statements in the current script block (if, while, then, else).
void Continue(String label_p, String condition_p)
performs Continue at the immediate while tag.
void abort(String msg_p)
raises Exception to cause the MBT execution to abort.
String add(String... exprList_p)
perform sum of all exprs.
void addDataSetRow(String... fieldList_p)
adds a row to the data set.
void addMScriptImpl(String javaClass_p, String javaFileName_p)
adds a custom MScript implementation to the current model from a java source code.
void addMScriptImpl(String javaClass_p)
adds a custom MScript implementation to the current model from a compiled java class (jar file or .class file) in the classpath.
void addTagCheck(String tag_p, String passed_p, String msg_p)
adds a tag check/validation message to the tag stat.
void addTagCheck(String tag_p, String passed_p, String msg_p, String assertID_p)
adds a tag check/validation message to the tag stat.
boolean and(String... exprList_p)
performs AND operation on the mScript expressions passed in that result in a boolean value and returns a true if all expressions evaluate to true, else return false.
int calearAllVars()
clears all user variables
String callFunc(String... cmdAndParams_p)
calls a user function with variable # of parameters.
String callURL(String urlString_p)
calls the url passed in and returns the content returned from the url.
String checkSeqNum()
returns the current seqNum without incrementing it.
String chooseMsg(String expr_p, String trueMsg_p, String falseMsg_p)
evaluates the expression passed in, if the expression evaluates to true, it returns the value from the trueMsg_p expression (may contain other mScript function calls).
void clearAllPathVars()
clears all variables on the current traversal path.
boolean compare(String expr1_p, String op_p, String expr2_p)
performs comparison between two expressions passed in using the operator specified.
boolean compare(String expr1_p, String op_p, String expr2_p, String caseSensitive_p)
int countSubstring(String inStr, String subStr)
Returns the count of occurrence of the substring subStr in the inStr
void dataSet(String... options_p)
creates a dataset using the dbName_p passed in as the data source.
String dataSetInfo(String dataSetID_p)
returns the data set info in a string.
void dataSource(String dbName_p, String connString_p, String driverClass_p, String user_p, String password_p)
adds a new data source to the model to be used for running sql query or load dataset.
String date(String dateExpr_p)
returns a date string in the default date format (MM/dd/yyyy or the format that you set with $setDateFormatLocale()).
String date()
returns todays date string in standard format: MM/dd/yyyy or the default format that you have set with $setDateFormatLocale().
String date(String dateExpr_p, String dateFmr_p)
returns a date string in java date format specified.
int datePart(String dateString_p, String partName_p)
returns a part of the date string passed in.
String decrement(String varName_p)
decrement the variable by 1.
String dequeue(String varName_p)
remove the first element in the queue.
void disableCommentToSeqOut()
disable outputing comment to SeqOut file.
String divide(String expr1, String expr2)
divide the first expr by the second.
String dumpExecState()
dump current model execution state and return it as a string.
void enableCommentToSeqOut()
enables auto output mscript comments to SeqOut file.
int enqueue(String varName_p, String value_p)
add the element to the end of the queue.
String envPeek(String varName_p)
peeks the last value in environment variable stack without pop it.
String envPop(String varName_p)
pops the last value from environment variable stack.
void envPopAll(String varName_p)
pop out all items in environment stack variable.
void envPush(String varName_p, String value_p)
push a value into a environment stack variable.
int envStackSize(String varName_p)
returns the count of elements currently in the stack/queue stored in environment variable.
String evalExpr(String expr_p)
performs mScript expression evaluation.
String evalMScript(String expr_p)
performs mScript expression evaluation.
boolean evalRegExpr(String inStr, String expr)
performs regular expression on the passed in text and returns true if regular expression has at least one match in the text.
String execSQL(String dbID_p, String sqlStmt_p, String colName_p, String delimeter_p)
executes an SQL statement and return the result from the specified column name with rows separated by the delimited specified
boolean execTrigger(String triggerName_p, String errIfNotFound_p)
runs the trigger in the current context (state or transition).
boolean execTrigger(String triggerName_p)
runs the trigger in the current context (state or transition).
Integer filterData(String... filterCond_p)
remove data row that match or not match the condition specified and return the count of rows removed.
Integer filterDataByThread(String dsID_p)
remove all rows from dataset except rows that match the current virtual user id.
String genMSC(String chartLabel_p, String fileName_p, String skinName_p, String bkgCoString)
generate Message Sequence Chart (MSC) from the home/start state to the current state.
String genMSC(String chartLabel_p, String fileName_p)
generate Message Sequence Chart (MSC) from the home/start state to the current state.
String genMSC(String chartLabel_p, String fileName_p, String skinName_p)
generate Message Sequence Chart (MSC) from the home/start state to the current state.
String genPath(String fileName_p)
generate traversal graph from home/start state to the current state.
String getAppURL()
returns the appURL for this plugin.
String getBrowser()
returns browser set for the model.
String getData(String dataSetID_p, String rowIdx_p, String fieldName_p)
return the field in the data set at the row specified in the rowIdx_p.
String getData(String dataSetIDFieldName_p)
returns the field in the data set at the current row.
String getData(String dataSetID_p, String fieldName_p)
return the field in the data set at the current row.
String[] getDataAllRows(String dataSetID_p, String fieldName_p)
returns column fieldName_p for all rows in the data set in a string separated by semi-colon ";".
String getDataSetRow(String dataSetID_p)
returns the current row in a string with key=value,key=value.
int getDataSetRowNum(String dataSetID_p)
returns the current row index.
int getDataSetSize(String dataSetID_p)
returns the number of rows (row count) in the dataset.
Object getEnvVar(String varName_p)
This method is deprecated. since 5.2
String getFuncParam(String paramName_p)
returns the param value for the user function in current scope.
String getNextMCase()
returns the next submodel MCase name if defined.
Object getPathVar(String varName_p)
retrieve a variable from the current traversal path.
String getPluginID()
returns ID of the plugin currently selected for the model.
String getStateProp(String propName_p)
returns the state property specified.
String getSysConfig(String propertyName_p, String defaultValue_p)
returns the property value from the system config.
String getSysConfig(String propertyName_p)
returns the property value from the system config.
String getSysVar(String varName_p)
Returns value for the system variable.
String getSysVar(String varName_p, String param_p)
returns system variable that requires a parameter.
String getTransData(String fieldName_p)
retrieves the DDT field value defined for the current transition.
String getTransProp(String propName_p)
returns the transition property specified.
String getTravVar(String varName_p)
retrives the value for a traversal variable (varialbes within scope of current transition/state traversal: state/transition.
Object getTravVarInternal(String varName_p)
INTERNAL USEONLY@return
String getVar(String varName_p, String index_p)
This method is deprecated. since 4.3.7
Object getVar(String varName_p)
Returns the value for the varName_p passed in.
String[] getVarAllRows(String varName_p)
This method is deprecated. since 4.3.7
void gotoState(String gotoStateID_p)
requests next state be set to the state id specified.
void gotoTrans(String gotoTransStateID_p, String gotoTransID_p)
requests the transition passed in be performed next.
void gotoURL(String url_p)
Set current web page to the url passed in.
String ifElseMsg(String expr_p, String trueMsg_p, String elseMsg_p)
evaluates the expression passed in, if the expression evaluates to true, it returns trueMsg_p expression (may contain other mScript function calls).
String ifFalseMsg(String expr_p, String msg_p)
evaluates the expression passed in, if the expression evaluates to false, it returns the message expression (may contain other mScript function calls).
String ifTrueMsg(String expr_p, String msg_p)
evaluates the expression passed in, if the expression evaluates to true, it returns the message expression (may contain other mScript function calls).
String increment(String varName_p)
increments the variable by 1.
String increment(String varName_p, String delta_p)
increment the variable by the delta passed in.
int indexOf(String inputString_p, String subString_p, String startPos_p)
returns the index of first occurrence of the substring specified in the input string starting at the start position specified.
int indexOf(String inputString_p, String subString_p)
returns the index of first occurrence of the substring specified in the input string.
String initCap(String text_p)
capitalize the first char of the text passed in.
boolean isDataSetBegin(String dataSetID_p)
returns true if the dataset is at the first row.
boolean isDataSetEnd(String dataSetID_p)
returns true if the dataset is at the last row.
boolean isEnvStackEmpty(String varName_p)
return true if stack/queue stored in environment variable is empty.
boolean isEnvVarDefined(String varName_p)
returns true if the environment variable specified has been set/defined/initialized.
String isEven(String expr)
returns true if the expr represents an even integer, else returns false.
boolean isFalse(String expr_p)
evaluates the mScript expression and return the negation of the boolean result from the expression.
boolean isModelRunning(String modelName_p)
returns true if the model specified is also running in the same server.
boolean isMultiThread()
returns true if current model execution is in multi-thread mode.
String isOdd(String expr)
returns true if the expr represents an od integer, else returns false.
boolean isStackEmpty(String varName_p)
return true if stack/queue is empty.
boolean isTrue(String expr_p)
evaluates the mScript expression and return true if the result is one of the representation of Boolean true: true, T, 1, yes, Y, etc.
boolean isValidDate(String dateString_p)
returns true if the date string passed in can be parsed by the default date format.
boolean isVarDefined(String varName_p)
returns true if the user variable specified has been set/defined/initialized.
String listFuncParams()
returns a string that represent parameters.
void loadFromDataSource(String... dsParams_p)
loads the data set from the data source defined with or without parameter.
void log(String level_p, String msg_p)
writes to MScript log file with specified log level.
void log(String msg_p)
writes to MScript log file.
String mod(String expr1_p, String expr2_p)
performs modulo operation expr1_p % expr2_p and returns the remainder.
String multiply(String expr1, String expr2)
multiply two exprs.
boolean nand(String... exprList_p)
performs NAND on the expression list passed.
String negate(String exprList_p)
perform the negation operation on the result from the expression passed in.
int nextDataSetRow(String dataSetID_p, String floatIdx_p)
moves the data set to a row randomly selected.
int nextDataSetRow(String dataSetID_p)
moves data set to next row.
int nextVarRow(String varName_p)
This method is deprecated. since 4.3.7
void noOut(String msg_p)
forces not to generate any output.
boolean nor(String... exprList_p)
performs NOR on the expression list passed.
boolean not(String expr_p)
evaluates the mScript expression and return the negation of the boolean result from the expression.
boolean or(String... exprList_p)
performs OR operation on the two mScript expressions passed in and returns a true if any of the expressions evaluates to true, else return false.
String osCmd(String cmd_p)
osCmd: runs an os command.
String osCmd(String cmd_p, String killAfterMillis_p)
osCmd: runs an os command, waits for the specified milliseconds and stops the application.
String osCmd(String cmd_p, String killAfterMillis_p, String logFileName_p)
osCmd: runs an os command, waits for the specified milliseconds and stops the application.
String osCmdAsynch(String cmd_p, String logFileName_p)
osCmd: runs an os command asynchronously.
String osCmdAsynch(String cmd_p)
osCmd: runs an os command asynchronously.
void pauseNext()
to request execution to be paused at the next pauseable position: mscript line or next traversal of state or transition.
String peek(String varName_p)
peeks the last value in stack without pop it.
String peekAt(String varName_p, String atIdx_p)
peeks at the element at the specified position/index.
String pop(String varName_p)
pops the last value from stack.
void popAll(String varName_p)
clears the stack.
String popAt(String varName_p, String atIdx_p)
Remove an element at the specified position from the stack described by the variable name.
int previousDataSetRow(String dataSetID_p)
moves data set to previous row.
void push(String varName_p, String value_p)
push a value into a stack variable.
int pushAt(String varName_p, String atIdx_p, String value_p)
Insert the value/element into the stack described by varName_p at the speified position (atIdx_p).
void raiseException(String level_p, String failedMsg_p)
raises an exception with the specified exception level.
int rand(String startInt_p, String endInt_p)
returns a random integer number between startInt_p (inclusive) and endInt_p (exclusive).
String rand(String startNum_p, String endNum_p, String precisionDigit_p)
returns a random integer number between startInt_p (inclusive) and endInt_p (exclusive).
int rand(String limit_p)
returns a random integer number between 0 (inclusive) and limit_p (exclusive).
float rand()
returns a random number in float between 0 (inclusive) and 1 (exclusive).
boolean randBool(String trueProb_p)
returns a randomly chosen true or false with the true probability.
boolean randBool()
returns a randomly chosen true or false.
Integer removeDataRow(String dataSetID_p, String fieldNames_p, String compValues_p)
removes rows from dataset that meet the specified criteria.
Integer removeDataRowExcept(String dataSetID_p, String fieldNames_p, String compValues_p)
removes rows from dataset that do not meet the specified criteria.
String replace(String inputString_p, String subString_p, String newString_p)
perform string replacement.
void requires(String libModelName_p)
imports external user functions into current model execution.
void requires(String libModelName_p, String libID_p)
imports external user functions into current model execution with a prefix library id.
void resetSeqNum()
resets the seqNum sys var to 0.
String resolveUIMap(String uiMap_p)
resolve UIMap path passed in and return the actual locator that would be passed to Selenium plugin for performing action.
void rewindDataSet(String dataSetID_p)
reset the data set to start at the first row.
int rewindVar(String varName_p)
This method is deprecated. since 4.3.7
int saveStats(String statDesc_p)
saves current execution stats to db and return the execID.
Integer searchData(String... searchParams_p)
searches for the data row that match the condition specified and return the count of rows matching the criteria and moves data set to the first matched row.
Integer searchDataRowIndex(String... searchParams_p)
searches for the data row that match the condition specified and return the count of rows matching the criteria and moves data set to the first matched row.
void sendMail(String fromAddress, String toAddress, String subject, String messageText)
send mail.
void sendMail(String toAddress, String subject, String messageText)
send mail.
synchronized void seqout(String seqText_p)
writes a message to seq.out (SeqOut) file in the model folder.
void setAppURL(String appURL_p)
sets AUT App/URL.
void setCurTransGuardHint(String hint_p)
change the transition's guard hint at runtime.
void setCurTransSatisfyingHint(String hint_p)
change the transition's satisfying hint at runtime.
boolean setData(String dataSetID_p, String fieldName_p, String value_p)
changes a field in the data set.
void setDataSetRow(String dataSetID_p, String rowIdx_p)
moves the data set to a row specified.
void setDateFormatLocale(String dateFormat_p, String dateTimeFormat_p, String locale_p)
sets the default date format and locale.
void setEnvVar(String varName_p, String toValue_p)
Set environment variable to the specified value.
void setFuncReturn(String retVal_p)
sets the return value for the current user function.
void setMaxTraverseTimes(String stateID_p, String transID_p, String maxTraverseTimes_p)
sets the maximum number of traversal for the specified transition.
void setMinTraverseTimes(String stateID_p, String transID_p, String minTraverseTimes_p)
sets the minimum number of traversal required for the specified transition.
void setNextMCase(String MCaseName_p)
sets the next mcase to be executed by the next submodel that has mcase implementation.
void setPathVar(String varName_p, String varVal_p)
sets a specific traversal path variable to the value passed in.
void setRecordingInerval(String millis)
change the screen recording interval.
boolean setSeed(String seed_p)
initialize random number generator used by the sequencer to the speific seed.
void setSeqNum(String seqNum_p)
sets sys var seqNum to the value specified.
void setSeqOutFile(String fileName_p)
sets the sequence output file.
void setStateResetURL(String stateID_p, String resetURL_p)
sets resetURL for the specified state.
void setTravVar(String varName_p, String val_p)
sets the value for the traversal variables.
boolean setVar(String varName_p, String toValue_p)
Set user variable to the specified value.
boolean setVar(String varName_p, String toValue_p, String modelName_p)
Sets a variable on a different model execution.
void setVarRowNum(String varName_p, String rowNum_p)
This method is deprecated. since 4.3.7
void setVarsFromDataSet(String dataSetID_p, String varPrefix_p)
create/set user variable for each column in the current row of the dataset.
void sleep(String millis_p)
sleeps for number of milliseconds.
List<String> snapScreen()
To cause a snapshot of current screen of each AUT by calling each plugins enabled for the model execution.
List<String> snapScreen(String fileName_p)
To cause a snapshot of current screen of each AUT by calling each plugins enabled for the model execution.
boolean soundAlike(String string1_p, String string2_p)
returns true if two strings sound like each other.
boolean soundAlike(String string1_p, String string2_p, String conf_p)
returns true if two strings sound alike with the degree of similarity specified.
boolean spellAlike(String string1_p, String string2_p, String conf_p)
returns true if two strings are spelled alike with up to specified degree of differences allowed.
boolean spellAlike(String string1_p, String string2_p)
returns true if two strings are spelled alike with up to specified degree of differences allowed.
String splitPiece(String inputString_p, String delimeter_p, String index_p)
returns nth piece of the input string split by the delimiter specified.
int stackSize(String varName_p)
returns the count of elements currently in the stack/queue.
void startScreenRecording(String recordingSetName)
starts screen recording and save the recording to the name specified.
void stopScreenRecording()
stop screen recording.
int stringLength(String inStr)
Returns the length of the string passed in.
String substract(String expr1_p, String expr2_p)
performs the substraction operation: expr1 - expr2.
String substring(String inputString_p, String startPos_p)
returns a substring of the input string starting at the position specified (inclusive) to the end of the string.
String substring(String inputString_p, String startPos_p, String endPos_p)
returns a substring of the input string between the start (inclusive) and end (exclusive) positions specified.
String time(String timeExpr_p)
returns time in a string in the format specified in the default date/time format as set by $setDateFormatLocale (defaulted to MM/dd/yyyy HH:mm).
String time(String timeExpr_p, String timeFmt_p)
returns a time string in java date/time format specified.
String time()
returns current time in string in standard time format MM/dd/yyyy HH:mm.
String toLowerCase(String text_p)
converts to lowercase.
String toUpperCase(String text_p)
converts to uppercase.
String trace(String maxLogCount_p)
returns the trace in a string of last maxLogCount_p traversals leading up to the current state/transition.
String trace()
returns the trace in a string of the traversals from the initial state to leading up to the current state/transition.
String trace(String maxLogCount_p, String delimiter_p)
returns the trace in a string of last maxLogCount_p traversals leading up to the current state/transition.
String trim(String text_p)
trims the leading and trailing space/blank characters from the text string.
String[] twitterGet(String user_p)
retrieves status update/message from the pre-configured twitter account.
void twitterPost(String msg_p)
sends a status update message to the twitter account pre-configured.
String waitForVarChanged(String varName_p, String timeoutMillis_p, String newValue_p)
waits until the variable specified has changed its value.
String waitForVarChanged(String varName_p)
waits until the variable specified has changed its value and return the new value.
String waitForVarChanged(String varName_p, String timeoutMillis_p)
waits until the variable specified has changed its value and return the new value.
String writeDataSet(String dataSetID_p, String outFileName_p, String delimiter_p, String fieldList_p)
writes the specified columns in dataset to file using specified column delimiter.
String writeDataSet(String dataSetID_p, String outFileName_p, String delimiter_p)
writes all columns in the dataset out to a file using the column delimiter specified.
boolean xor(String... exprList_p)
performs XOR on the expression list passed.
[Expand]
Inherited Methods
From class java.lang.Object

Public Methods

public void Break (String label_p, String condition_p)

Since: API Level v2

performs Break on the current mscript block when the condition specifed evaluates to true.

Parameters
label_p label of an mscript block
condition_p an mscript expression that evaluates to true or false.
Throws
MBTBreakException
Exception

public void Break (String label_p)

Since: API Level v2

performs Break on the mscript block identified by the parameter

Parameters
label_p label of an mscript block
Throws
MBTBreakException
Exception

public void Break ()

Since: API Level v2

performs Break on the current mscript tag, e.g. if, while, then, else.

Throws
MBTBreakException

public void Continue (String label_p)

Since: API Level v2

perform Continueon the while loop identified.

Example:

$Continue ('while2')

Parameters
label_p label of an mscript block.
Throws
Exception

public void Continue ()

Since: API Level v2

skip the rest of the statements in the current script block (if, while, then, else).

Throws
MBTContinueException

public void Continue (String label_p, String condition_p)

Since: API Level v2

performs Continue at the immediate while tag.

Example:

$Continue ('[var1] eq 2', 'loop1')
The above expression performs Continue at the while loop labeled with loop1 when the user variable var1 is set to 2.

Parameters
label_p mscript block label
condition_p a boolean value or an mscript expression that evalues to true or false
Throws
Exception

public void abort (String msg_p)

Since: API Level v2

raises Exception to cause the MBT execution to abort.

Can be used anywhere in mScript. It will trigger if one is declared.

This function is ignored when running the model in debug mode and AUT is disabled. The reason for this behavior is to allow users to continue to debug MScript error. Instead of abort the execution, it will just display an abort alert message indicating where the abort was triggered.

Example:

<if val1="$containsText('FATAL ERROR XYZ')" op="eq" val2="true">
    <action code="$abort('Fatal error detected')"/>
</if>

Throws
Exception

public String add (String... exprList_p)

Since: API Level v2

perform sum of all exprs.

Example:

<action code="$add('$getVar('a')', '2')"/>

Returns
  • result value
Throws
Exception

public void addDataSetRow (String... fieldList_p)

Since: API Level v2

adds a row to the data set.

Example:

$addDataSetRow ('ds1','f1=v1','f2=v2')

Throws
MBTException
MBTException

public void addMScriptImpl (String javaClass_p, String javaFileName_p)

Since: API Level v2

adds a custom MScript implementation to the current model from a java source code. This function overrides the system defined custom MScript implementation as defined in config (MSCRIPT_IMPL=myJavaClassPath).

MScript implementation is a java class that provides a collection of java methods exposed to mScript and can be called with $_methodName() syntax. Notice the prefix of "_" right after "$" symbol while "methodName" is the actual java method name in your java class and notice that java method name in the java class does NOT contain prefix "_" nor "$" symbol in the method name.

This function is not available in BasicMBT edition.

All public java methods are automatically exposed as MScript methods and can be called like any MScript methods.

For example, place the action script in mbt_start trigger to add your mscript implementation and log script anywhere in your mscript to call your mscript function:
<action code="$addMScriptImpl('demo.customPlugin.MyMScritpMethodClass','file1.java')"/>
<log msg="calling my mScript method method_2: $_myMethod_2('a','b','c')"/>

Below is an example of the mscript implementation java class. Notice that the constructor with one parameter of MbtScriptExecutor is required.

 package demo.customPlugin;
 import com.webmbt.plugin.MbtScriptExecutor;
 
 public class MyMScriptMethodClass {
 		private MbtScriptExecutor scriptExec;
 
 		// Required constructor of the exact signature!
 		public MyMScriptMethodClass(MbtScriptExecutor scriptExec_p) {
 			// save MbtScriptExecutor object passed in for later use. You can access to
 			// plugins activated for the model through scriptExec.
 			scriptExec = scriptExec_p;
 
 			// add your initialization code here.
 			System.out.println("# of plugins activated: " + scriptExec_p.getPluginList().size());
 		}
 
 		public String myMethod_1() {
 			System.out.println ("myMethod_1 called");
 			return "OK";
 		}
 
 		public String myMethod_2(String ... params_p) {
 			System.out.println ("myMethod_2 called with " + params_p.size() + " params");
 			return "OK";
 		}
 
 		// close method is optional.
 		public void close() {
 			System.out.println ("closing");
 		}
 }
 

To deploy the mscript implementation java class, just like create the java class and save as a text file in the model folder or /script/ folder. The java source code will be dynamically compiled and loaded into memory.

The difference between this function and addMScriptImpl(String) (single argument) is that this function dynamically compiles mscript class from the source code provided in the fileName while addMScriptImpl(String) needs to be pre-compiled into jar file.

Parameters
javaClass_p java class name with path, e.g. com.mycompany.mypackage.myJavaClass.
javaFileName_p file name of the java source code file stored in the model folder or in /script/ folder or absolute file path.
Throws
Exception
Exception
See Also
  • addMScriptImpl(String)

public void addMScriptImpl (String javaClass_p)

Since: API Level v2

adds a custom MScript implementation to the current model from a compiled java class (jar file or .class file) in the classpath. This function overrides the system defined custom MScript implementation as defined in config (MSCRIPT_IMPL=myJavaClassPath).

MScript implementation is a java class that provides a collection of java methods exposed to mScript and can be called with $_methodName() syntax. Notice the prefix of "_" right after "$" symbol while "methodName" is the actual java method name in your java class and notice that java method name in the java class does NOT contain prefix "_" nor "$" symbol in the method name.

This function is not available in BasicMBT edition.

All public java methods are automatically exposed as MScript methods and can be called like any MScript methods.

For example, place the action script in mbt_start trigger to add your mscript implementation and log script anywhere in your mscript to call your mscript function:
<action code="$addMScriptImpl('demo.customPlugin.MyMScritpMethodClass')"/>
<log msg="calling my mScript method method_2: $_myMethod_2('a','b','c')"/>

Below is an example of the mscript implementation java class.

 package demo.customPlugin;
 import com.webmbt.plugin.MbtScriptExecutor;
 
 public class MyMScriptMethodClass {
 		private MbtScriptExecutor scriptExec;
 
 		// Required constructor of the exact signature!
 		public MyMScriptMethodClass(MbtScriptExecutor scriptExec_p) {
 			// save MbtScriptExecutor object passed in for later use. You can access to
 			// plugins activated for the model through scriptExec.
 			scriptExec = scriptExec_p;
 
 			// add your initialization code here.
 			System.out.println("# of plugins activated: " + scriptExec_p.getPluginList().size());
 		}
 
 		public String myMethod_1() {
 			System.out.println ("myMethod_1 called");
 			return "OK";
 		}
 
 		public String myMethod_2(String ... params_p) {
 			System.out.println ("myMethod_2 called with " + params_p.size() + " params");
 			return "OK";
 		}
 
 		// close method is optional.
 		public void close() {
 			System.out.println ("closing");
 		}
 }
 

To deploy the mscript implementation java class, just like deploying the java plugin, compile it, package the ".class" files into ".jar" file, copy ".jar" file to "/lib" folder and restart the server.

Throws
MBTException
Exception
See Also
  • addMScriptImpl(String,String)

public void addTagCheck (String tag_p, String passed_p, String msg_p)

Since: API Level v2

adds a tag check/validation message to the tag stat. A tag check/validation usually is a result of an assert. A tag may have many checks/validations per traversal of the state/transition which the tag is assigned to.

Each check/validation may pass or fail. When failed, the message will be added to the tag stats to be tallied.

Parameters
tag_p one single tag id
passed_p "Y" or "pass" for passed, "N" or "fail" for failed
msg_p message to be added to this check.
Throws
Exception

public void addTagCheck (String tag_p, String passed_p, String msg_p, String assertID_p)

Since: API Level v2

adds a tag check/validation message to the tag stat. A tag check/validation usually is a result of an assert. A tag may have many checks/validations per traversal of the state/transition which the tag is assigned to.

Each check/validation may pass or fail. When failed, the message will be added to the tag stats to be tallied.

Parameters
tag_p one single tag id
passed_p "Y" or "pass" for passed, "N" or "fail" for failed
msg_p message to be added to this check.
assertID_p user assigned unique id for this specific call, this is usually used to find the same defect in the defect system from previous runs.
Throws
Exception

public boolean and (String... exprList_p)

Since: API Level v2

performs AND operation on the mScript expressions passed in that result in a boolean value and returns a true if all expressions evaluate to true, else return false.

Each mscript expression must evaluates to true or false individually, all non boolean expressions will be evaluated to false unless they result in one of the following value that evaluates to true automatically:

yes, y, t, 1, on, checked, selected, valid, pass, passed.

Example:

$and('[seqNum] gt 1', '[seqNum] lt 10')
The above expression returns true when seqNum var is greater than 1 and less than 10.

You may specify the mScript expression in value1 op value2 where value1 and value2 can be any regular mscript exprsesion including calls to other mscript methods.

Example:

$and('[var1] gt 20', '$getData('ds1','loginID') eq Good')

You may have as many mscript expression as you need.

Empty expressions are ignored, equivalent to being evaluated to true.

Parameters
exprList_p list of expressions, each expression in a separate parameter.
Returns
  • true/false
Throws
Exception

public int calearAllVars ()

Since: API Level v2

clears all user variables

Returns
  • number of variables cleared

public String callFunc (String... cmdAndParams_p)

Since: API Level v2

calls a user function with variable # of parameters. Parameters can be either named or unname:

  1. named parameter: 'paramName=paramValue'
  2. unnamed parameter: 'paramValue'

Example:

$callFunc ('myFunc', 'firstName=John', 'lastName=Smith')
$callFunc ('myFunc', 'John', 'lastName=Smith')

The first example uses named parameter and thus the paramters can be retrieved by the parameter names specified.

The second example uses the combination of unnamed (first) parameter and named (second) parameter. Thus the first parameter must be retrieved by the position while the second paramter must be retrieved by name.

If the param value contains "=", you must use named parameter syntax.

The unnamed parameters are identifed by its position index starting at 1 for the first parameter.

Returns
  • a String set by mscript method $setFuncReturn('val')
Throws
Exception
Exception
See Also
  • callFunc(String)

public String callURL (String urlString_p)

Since: API Level v2

calls the url passed in and returns the content returned from the url.

Returns
  • url content. if errored, return ERROR: error msg

public String checkSeqNum ()

Since: API Level v2

returns the current seqNum without incrementing it.

Example:

$checkSeqNum()

Returns
  • current sequence number

public String chooseMsg (String expr_p, String trueMsg_p, String falseMsg_p)

Since: API Level v2

evaluates the expression passed in, if the expression evaluates to true, it returns the value from the trueMsg_p expression (may contain other mScript function calls). Otherwise, it returns the value from the falseMsg_p expression.

Example:

$chooseMsg('[var1] gt 5', 'variable var1 is greater than 5', 'variable var1 is less than or equal to 5')
The above expression will return the message 'variable var1 is greater than 5' when the variable 'var1' has a value greater than 5, else it returns the second message.

@ifTrueMsg()@ifFalseMsg()

Returns
  • value from either trueMsg_p or falseMsg_p expression
Throws
Exception
Exception

public void clearAllPathVars ()

Since: API Level v2

clears all variables on the current traversal path.

Example:

$clearAllPathVars()

Throws
MBTException

public boolean compare (String expr1_p, String op_p, String expr2_p)

Since: API Level v2

performs comparison between two expressions passed in using the operator specified. The match is performed based on the operator.

Example:

$compare('[var1]','eq','[var2]')
The above expression compares the values in var1 and var2 and return the true if they are equal.

Returns
  • true or false
Throws
Exception
Exception

public boolean compare (String expr1_p, String op_p, String expr2_p, String caseSensitive_p)

Since: API Level v2

Throws
Exception

public int countSubstring (String inStr, String subStr)

Since: API Level v2

Returns the count of occurrence of the substring subStr in the inStr

public void dataSet (String... options_p)

Since: API Level v2

creates a dataset using the dbName_p passed in as the data source. Use $addDataSetRow('ds1','f1=val1','f2=val2') to populate dataset or $loadFromDataSource('ds1') to populate the dataset from the data source defined for the dataset.

Example:

$dataSource('ds1', 'dbName=db1', 'autoRewind=Y')

Parameters
options_p key=value list, keys include: dbName, autoRewind, append. Keys are case sensitive!

public String dataSetInfo (String dataSetID_p)

Since: API Level v2

returns the data set info in a string.

Use this method for debugging to examine the status of the data set.

Example:

<log msg="$dataSetInfo('ds1')"/>

Parameters
dataSetID_p data set id
Returns
  • a string the describes the data set.

public void dataSource (String dbName_p, String connString_p, String driverClass_p, String user_p, String password_p)

Since: API Level v2

adds a new data source to the model to be used for running sql query or load dataset.

public String date (String dateExpr_p)

Since: API Level v2

returns a date string in the default date format (MM/dd/yyyy or the format that you set with $setDateFormatLocale()). Supports several variation of date expressions: today, yesterday, tomorrow, +1D, -1D, +1M, -1M, +1Y, -1Y. For example "$date('-1D')" returns yesterday's date.

Parameters
dateExpr_p date expression as described above.
Returns
  • date string
Throws
MBTException

public String date ()

Since: API Level v2

returns todays date string in standard format: MM/dd/yyyy or the default format that you have set with $setDateFormatLocale().

Returns
  • date string
Throws
MBTException

public String date (String dateExpr_p, String dateFmr_p)

Since: API Level v2

returns a date string in java date format specified. Supports several variation of date expressions: today, yesterday, tomorrow, +1D, -1D, +1M, -1M, +1Y, -1Y.

Parameters
dateExpr_p date expression as described above.
dateFmr_p date format to be used to format the date into string. Accept java date simple date format, for example "MM/dd/yyyy". You may also use "epoch" as the format string to retrieve date in number of milliseconds since Jan. 1, 1970 (epoch time).
Returns
  • date string
Throws
MBTException
See Also
  • http://download.oracle.com/javase/6/docs/api/java/text/SimpleDateFormat.html

public int datePart (String dateString_p, String partName_p)

Since: API Level v2

returns a part of the date string passed in.

Parameters
dateString_p a date string that can be parsed by default date format (or the date format that you set by $setDateFormatLocale()).
partName_p year, month, day, day_of_year, week_of_month, week_of_year and hour, minute, second.
Returns
  • integer representation of the date part specified according in java lanuguage.
Throws
Exception

public String decrement (String varName_p)

Since: API Level v2

decrement the variable by 1.

Example:

<action code="$decrement('countVar')"/>

Parameters
varName_p variable name
Returns
  • new value
Throws
Exception

public String dequeue (String varName_p)

Since: API Level v2

remove the first element in the queue. The queue is implemented as FIFO (first in first out). Queue and Stack are implemented using java array list. You may call enqueue/dequeue/push/pop/... on the same stack/queue variable.

First element in the queue is element 0 in the queue array.

Returns
  • value of the queue entry retrieved
Throws
MBTException

public void disableCommentToSeqOut ()

Since: API Level v2

disable outputing comment to SeqOut file. Use this to temporarily disable the output of comments to SeqOut.

public String divide (String expr1, String expr2)

Since: API Level v2

divide the first expr by the second. That is: expr1 / expr2.

Example:

<action code="$divide('$getVar('a')', '2')"/>

Returns
  • result of the division or "E" if divisor is zero.
Throws
Exception

public String dumpExecState ()

Since: API Level v2

dump current model execution state and return it as a string. The state includes user variables, system variables and dataset state.

Use this function to obtain the current state and write it to mscript log file for debugging and trouble shooting.

Commonly used in onError trigger or onFailure trigger.@return

public void enableCommentToSeqOut ()

Since: API Level v2

enables auto output mscript comments to SeqOut file. Call this function in MBT_start trigger or any other trigger. All subsequent mscript comments will be automatically written to SeqOut file as mScript is executed until $disableCommentToSeqOut() is called.

Optionally you can call $setSeqOutFile(filename) to name the SeqOut file.

Example:

$enableCommentToSeqOut()

Do not use this function with SeqOut plugin.

Throws
MBTException
See Also
  • #setSeqOutFile(), #disableCommentToSeqOut()

public int enqueue (String varName_p, String value_p)

Since: API Level v2

add the element to the end of the queue. The queue is implemented as FIFO (first in first out). Queue and Stack are implemented using java array list. You may use mix use enqueue/dequeue/push/pop/... on the same stack/queue variable.

First element in the queue is element 0 in the queue array.

Returns
  • position of the entry in the queue
Throws
MBTException

public String envPeek (String varName_p)

Since: API Level v2

peeks the last value in environment variable stack without pop it. Stack is consistent with java stack implementation: First-In, Last Out (FILO).

Example:

$envPeek('myStack')
The above expression retrieves the last value in the stack but does not pop the last value out of the stack.

Parameters
varName_p name of the variable.
Returns
  • the value last pushed into the stack or blank if stack is empty.
Throws
Exception on inconsistent use of the stack variable, for example the variable was previously used as a single variable.
MBTException
See Also
  • #envPeekAt(String, String)

public String envPop (String varName_p)

Since: API Level v2

pops the last value from environment variable stack. Stack is consistent with java stack implementation: First-In, Last Out (FILO).

Example:

$envPop('myStack')

Parameters
varName_p name of the stack variable.
Returns
  • variable value
Throws
Exception on inconsistent use of the stack variable, for example the variable was previously used as a single variable.
MBTException

public void envPopAll (String varName_p)

Since: API Level v2

pop out all items in environment stack variable.

public void envPush (String varName_p, String value_p)

Since: API Level v2

push a value into a environment stack variable. Stack is consistent with java stack implementation: First-In, Last Out (FILO).

Example:

$envPush('myStack', 'xx')
The above expression will push 'xx' to the end of list of values for 'myStack'. You will then use "$envPop('myStack')" to retrieve the last value in the stack.

Parameters
varName_p name of the variable.
value_p value to be pushed to the stack.
Throws
Exception if the inconsitent use of the variable. That is, if the variable was previous used as a single string variable.
MBTException

public int envStackSize (String varName_p)

Since: API Level v2

returns the count of elements currently in the stack/queue stored in environment variable.

Returns
  • stack size

public String evalExpr (String expr_p)

Since: API Level v2

performs mScript expression evaluation. This is used to force the mscript expression to be evaluated, typically used to force custom plugin method call to be evaluated when it's used to return value. If the result string is a form of a boolean expression: string1 op string 2, it also performs the boolean evaluation and return the result of the boolean operation.

Example:

$setVar('v1', '$evalExpr('$_myCustMethod('p1')')')

Returns
  • value from the expr_p
Throws
Exception
Exception
See Also
  • evalMScript(String)

public String evalMScript (String expr_p)

Since: API Level v2

performs mScript expression evaluation. This is used to evaluate a string consisting mscript variables and mscript function.

Example:

$setVar('v1', '$evalMScript('$_myCustMethod('p1')')')

Returns
  • value from the expr_p
Throws
Exception
Exception
See Also
  • evalExpr(String)

public boolean evalRegExpr (String inStr, String expr)

Since: API Level v2

performs regular expression on the passed in text and returns true if regular expression has at least one match in the text. If either passed in text or regular expression is blank, it returns true.

Returns
  • true/false

public String execSQL (String dbID_p, String sqlStmt_p, String colName_p, String delimeter_p)

Since: API Level v2

executes an SQL statement and return the result from the specified column name with rows separated by the delimited specified

Parameters
dbID_p db id defined in mScript db tag
sqlStmt_p sql statement, insert, update, stored procedure call, etc.
colName_p name of the column to return, only used for select statement. pass "" for other statements. You can pass in column index (1-based) or blank for first column.
delimeter_p row delimited to be used to seperate values from different rows, only used for select.
Returns
  • # of rows affected for insert/update/delete, status return from stored procedure or column values for select.
Throws
Exception
Exception

public boolean execTrigger (String triggerName_p, String errIfNotFound_p)

Since: API Level v2

runs the trigger in the current context (state or transition). If first searches for the trigger in the current state or transition, if not found it then searches in MBT context. Be aware that the trigger name must be unique within the context. Because the search falls back to MBT context, take caution to name the triggers with distinct names to avoid name conflict.

Example:

$execTrigger ('myTrigger', 'true')

Parameters
triggerName_p name of the trigger to be executed. System triggers like 'action', 'onError', etc. may be used. Be aware that recursive execution of triggers may cause inifinite loop. Use Call Hierarchy diagram to check for recursive trigger calls.
Returns
  • true if trigger is found and executed.
Throws
Exception

public boolean execTrigger (String triggerName_p)

Since: API Level v2

runs the trigger in the current context (state or transition). If first searches for the trigger in the current state or transition, if not found it then searches in MBT context. Be aware that the trigger name must be unique within the context. Because of search fall back to MBT context, take caution to name the triggers with distinct names to avoid name conflict.

Example:

$execTrigger ('myTrigger')

Parameters
triggerName_p name of the trigger to be executed. System triggers like 'action', 'onError', etc. may be used. Be aware that recursive execution of triggers may cause inifinite loop. Use Call Hierarchy diagram to check for recursive trigger calls.
Returns
  • true if trigger is found and executed
Throws
Exception

public Integer filterData (String... filterCond_p)

Since: API Level v2

remove data row that match or not match the condition specified and return the count of rows removed. filter conditions specified are "AND" together. You can specify one condition on one field per search condition.

The filterCondition must be an MScript expression that evaluates to true or false using the format of 'fieldName' 'operator' 'filterPattern' where fieldName must be a valid field name within the specified dataset.

The operator can be one of the following (same as the op in AssertTag):

  • gt - greater than
  • lt - less than
  • ge - greater than or equal to
  • le - less than or equal to
  • eq - equal to
  • ne - not equal to
  • in - matching one of the values separated by comma (,)
  • between - between two numbers separated by comma (,) or and
  • contains - containing the text
  • startsWith - starting with (prefix) of a text
  • endsWith - ending with (suffix) of a text
  • match - matching regular expression
  • soundsLike - matching soundex
  • spellsLike - less than 10% different in chars
  • NOTin - not in one of the values separated by comma (,)
  • NOTbetween - not between two numbers separated by comma (,) or and
  • NOTcontains - not containing the text
  • NOTstartsWith - not starting with the text
  • NOTendsWith - not ending with the text
  • NOTmatch - not matching the regular expression specified
  • NOTsoundsLike - not matching soundex specified
  • NOTspellsLike - having over 15% different in chars

Example:

<action log="# of rows removed with DEPOSIT payment type and deposit amount less than $5000: $filterData('ds1','PaymentType eq DEPOSIT', 'Amount lt 5000')"/>

Returns
  • count of rows removed
Throws
MBTException
Exception

public Integer filterDataByThread (String dsID_p)

Since: API Level v2

remove all rows from dataset except rows that match the current virtual user id.

Returns
  • count of rows left in the dataset.
Throws
Exception

public String genMSC (String chartLabel_p, String fileName_p, String skinName_p, String bkgCoString)

Since: API Level v2

generate Message Sequence Chart (MSC) from the home/start state to the current state. Typically you would call this function in the final state's onentry trigger to generate a test sequence that corresponds to a test case / scenaio.

CAUTION: this function is not thread-safe, i.e. if you are running multiple concurrent threads, the behavior may be un-predictable - it may contain traversals from other threads concurrently running.

Parameters
fileName_p name of the image file without extension. You may include "." in the file name, but the system will add file extension that matches the image even if you have supplied the right extension.
skinName_p name of the skin (Rose or BlueModern) to style the MSC.
Returns
  • absolute file path to the image generated, which is the report folder of the model.
Throws
Exception

public String genMSC (String chartLabel_p, String fileName_p)

Since: API Level v2

generate Message Sequence Chart (MSC) from the home/start state to the current state. Typically you would call this function in the final state's onentry trigger to generate a test sequence that corresponds to a test case / scenaio.

CAUTION: this function is not thread-safe, i.e. if you are running multiple concurrent threads, the behavior may be un-predictable - it may contain traversals from other threads concurrently running.

Parameters
fileName_p name of the image file without extension. You may include "." in the file name, but the system will add file extension that matches the image even if you have supplied the right extension.
Returns
  • absolute file path to the image generated, which is the report folder of the model.
Throws
Exception

public String genMSC (String chartLabel_p, String fileName_p, String skinName_p)

Since: API Level v2

generate Message Sequence Chart (MSC) from the home/start state to the current state. Typically you would call this function in the final state's onentry trigger to generate a test sequence that corresponds to a test case / scenaio.

CAUTION: this function is not thread-safe, i.e. if you are running multiple concurrent threads, the behavior may be un-predictable - it may contain traversals from other threads concurrently running.

Parameters
fileName_p name of the image file without extension. You may include "." in the file name, but the system will add file extension that matches the image even if you have supplied the right extension.
skinName_p name of the skin (Rose or BlueModern) to style the MSC.
Returns
  • absolute file path to the image generated, which is the report folder of the model.
Throws
Exception

public String genPath (String fileName_p)

Since: API Level v2

generate traversal graph from home/start state to the current state. Typically you would call this function in the final state's onentry trigger to generate a test path that corresponds to a test case/scenario.

CAUTION: this function is not thread-safe, i.e. if you are running multiple concurrent threads, the behavior may be un-predictable - it may contain traversals from other threads concurrently running.

Parameters
fileName_p name of the image file without extension. You may include "." in the file name, but the system will always add file extension that matches the image even if you have supplied the right extension.
Returns
  • absolute file path to the image generated, which is the report folder of the model.
Throws
Exception

public String getAppURL ()

Since: API Level v2

returns the appURL for this plugin. appURL is set in model property AppURL. If you are testing more than windows UI, You can prefix your app path with "win:" to separate windows appURL from the other AUTs you are testing together.

To retrieve appURL applicable for the plugin, use the plugin specific function $getPluginAppURL()

Returns
  • app URL as set for the model.

public String getBrowser ()

Since: API Level v2

returns browser set for the model.

Returns
  • iexplore, firefox, custom, konqueror, chrome, safari, opera, etc.

public String getData (String dataSetID_p, String rowIdx_p, String fieldName_p)

Since: API Level v2

return the field in the data set at the row specified in the rowIdx_p.

Example:

<log msg="current row F1 on myDS: $getData('myDS','F1')"/>

Parameters
dataSetID_p data set id
rowIdx_p row index
fieldName_p field name
Returns
  • string value of the field
Throws
MBTException

public String getData (String dataSetIDFieldName_p)

Since: API Level v2

returns the field in the data set at the current row. The data set is specified in dataSetIdFieldName_p as: dataSetID:fieldName.

Example:

$getData('ds1:f1')
The above expression will return the value of field "f1" in data set "ds1" at the current row.

Parameters
dataSetIDFieldName_p data set id and field name combined separated by colon ":".
Returns
  • field value
Throws
MBTException

public String getData (String dataSetID_p, String fieldName_p)

Since: API Level v2

return the field in the data set at the current row.

Example:

<log msg="current row F1 on myDS: $getData('myDS','F1')"/>

Parameters
dataSetID_p data set id
fieldName_p field name
Returns
  • string value of the field
Throws
MBTException

public String[] getDataAllRows (String dataSetID_p, String fieldName_p)

Since: API Level v2

returns column fieldName_p for all rows in the data set in a string separated by semi-colon ";".

Example:

<log msg="DataSet myDS.F1: $getDataAllRows('myDS', 'F1')"/>

Parameters
dataSetID_p data set id
fieldName_p field name
Returns
  • a string the represents the result. If an array was returned, the array elements will be strung with semi-colon as the delimeter.
Throws
MBTException

public String getDataSetRow (String dataSetID_p)

Since: API Level v2

returns the current row in a string with key=value,key=value.

Example:

<log msg="current dataset row for myDS: $getDataSetRow('myDS')"/> 

Parameters
dataSetID_p data set id
Returns
  • a string the represents the entire row of current row in the data set.
Throws
MBTException

public int getDataSetRowNum (String dataSetID_p)

Since: API Level v2

returns the current row index.

Example:

<log msg="current dataset row for myDS: $getDataSetRowNum('myDS')"/>

Parameters
dataSetID_p data set id
Returns
  • current row number (index), -1 for unknown dataset or data set not loaded, 0 for first row.

public int getDataSetSize (String dataSetID_p)

Since: API Level v2

returns the number of rows (row count) in the dataset.

Example:

<log msg="current dataset row for myDS: $getDataSetSize('myDS')"/>

Parameters
dataSetID_p data set id
Returns
  • row count in dataset, 0 if empty,-1 if dataset is not defined.

public Object getEnvVar (String varName_p)

Since: API Level v2

This method is deprecated.
since 5.2

Returns the value for the environment variable (global variable in current server) at the index passed in.

Example:

$getEnvVar('var1')

Parameters
varName_p name of the variable.
Returns
  • a string representation of the value for the variable.
Throws
MBTException

public String getFuncParam (String paramName_p)

Since: API Level v2

returns the param value for the user function in current scope. Should only be called within the scope of a user function or nested mscript tag within the user function.

This function always returns blank when is called from a non-state or transition context, e.g. in Mbt_start.

Example:

$getFuncParam('loginID')

Parameters
paramName_p name of the param.
Returns
  • String value of the parameter
Throws
Exception
Exception

public String getNextMCase ()

Since: API Level v2

returns the next submodel MCase name if defined. returns null/blank if it is set/defined or the MCase has already been or is being executed.@return

Throws
MBTException

public Object getPathVar (String varName_p)

Since: API Level v2

retrieve a variable from the current traversal path.

Example:

$getPathVar('messageTriggered')
 

Parameters
varName_p name of the path variable
Returns
  • value of the path variable
Throws
MBTException if path variable is not found.

public String getPluginID ()

Since: API Level v2

returns ID of the plugin currently selected for the model. This is equivalent to system var [plugin].

Returns
  • SELENIUM, JAVAPLUGIN, etc.

public String getStateProp (String propName_p)

Since: API Level v2

returns the state property specified. Use property name in State Property dialog.

  1. RESET URL
  2. SUB MODEL NAME
  3. TAGS
  4. INITIAL STATE
  5. FINAL STATE
  6. Stereotype

For example:

<log msg="Is Initial Node: $getStateProp('INITIAL STATE')"/>

Returns
  • property value
Throws
Exception

public String getSysConfig (String propertyName_p, String defaultValue_p)

Since: API Level v2

returns the property value from the system config. If property does not exist, return the defaultValue_p passed in.

Parameters
propertyName_p name of the property
Returns
  • configuration value

public String getSysConfig (String propertyName_p)

Since: API Level v2

returns the property value from the system config.

Parameters
propertyName_p name of the property
Returns
  • null/blank if property does not exist.

public String getSysVar (String varName_p)

Since: API Level v2

Returns value for the system variable. The following system variables are supported:

  • appURL: returns the app url as defined for the model
  • AUTVersion: AUT version number specified for the model
  • curAssertID: assertID defined for the current state/transition. If trans assertID not defined, default to state assertID.
  • curStateID: current state id
  • curStateDesc: current state description
  • curStateTags: tags of current state
  • curTags: same as getSysVar('tags'). tags defined for the current state/transition. If trans tags not defined, default to state tags.
  • curTransDesc: current transition description
  • curTransEvent or curTransID: current transition event (id)
  • curTransTags: tags of current transition
  • curStateTravCount: number of times the current state has been visited (traversed)
  • curTransTravCount: number of times the current transition has been triggered (traversed).
  • targetStateID: target state if in trans context, else returns current state id
  • exceptionNum: number of exceptions so far has been triggered.
  • javaVersion: java version TestOptimal server is current running
  • licEmail: Licensed Email address.
  • mCaseExecNum: number of times the current mCase has been executed.
  • mCaseTags: tags of current mCase has been executed.
  • mCaseName: name of current mCase being executed.
  • ModelAbsolutePath: return the absolute file path for the current model
  • ModelName: return the name of the model currently running
  • ModelRelativePath: return the relative file path for the current model from the model root
  • ModelRoot: return the model root of current server installation
  • modelVersion: model version number specified for the model
  • osName: OS Name
    • windows
    • mac
    • linux
    • solaris
  • prevStateID: previous state leading to the current state
  • plugin: id(s) of plugin enabled for this execution
  • prevTransEvent: the transition that led to the current state
  • seqNum: generated sequence number (starting at 0), increment by 1 for each call
  • serverName: TestOptimal server host name
  • serverIP: TestOptimal server ip address
  • stateTags: tags defined for the current state
  • stateTravCount: number of state traversals
  • tags: same as getSysVar('curTags'). tags defined for the current state/transition. If trans tags not defined, default to state tags.
  • threadID: virtual user thread number.
  • toVersion: TestOptimal version
  • transTags: tags defined for the current transition
  • transTravCount: number of transition traversals
  • versionTag: tag version number from requirements system
  • debug: if in debug execution or animate/play execution
  • runAUT: if invoking AUT (AUT model enabled)

Example:

$getSysVar('curStateID')
The above expression returns the ID of the current state. With release 3.0, you may use token syntax to access system var like [curStateID].

Returns
  • value of the system variable, blank if not found
Throws
Exception

public String getSysVar (String varName_p, String param_p)

Since: API Level v2

returns system variable that requires a parameter.

  • varName_p = 'exceptionNum', param_p = '{L1 - L5}': returns the number of exceptions triggered for the exception level specified in the parameter (L1 - L5).

Parameters
varName_p name of the variable
param_p parameter
Returns
  • value of the system variable, blank if not found.
Throws
Exception

public String getTransData (String fieldName_p)

Since: API Level v2

retrieves the DDT field value defined for the current transition.

Returns
  • data value
Throws
MBTException

public String getTransProp (String propName_p)

Since: API Level v2

returns the transition property specified. Use property name in Transition Property dialog.

  1. GUARD
  2. TAGS
  3. STEREOTYPE
  4. TRAVERSALS REQUIRED

Returns
  • property value
Throws
Exception

public String getTravVar (String varName_p)

Since: API Level v2

retrives the value for a traversal variable (varialbes within scope of current transition/state traversal: state/transition. Throws exception if variable has not been set.@return

Throws
MBTAbort
MBTAbort
See Also
  • setTravVar(String,String)

public Object getTravVarInternal (String varName_p)

Since: API Level v2

INTERNAL USEONLY@return

Throws
MBTAbort

public String getVar (String varName_p, String index_p)

Since: API Level v2

This method is deprecated.
since 4.3.7

Returns the value for the variable at the index passed in.

Example:

$getVar('var1', '2')
The above expression will return the 2nd value in the variable.

Parameters
varName_p name of the variable.
index_p 0-based index
Returns
  • a string representation of the value for the variable.

public Object getVar (String varName_p)

Since: API Level v2

Returns the value for the varName_p passed in. It first check the user var list, if it's not found, it checks the pat var list.

Example:

$getVar('myVar1')
You may use token syntax to access system var like "[myVar1]".

Parameters
varName_p name of the user variable.
Returns
  • value for the variable
Throws
MBTAbort
MBTException

public String[] getVarAllRows (String varName_p)

Since: API Level v2

This method is deprecated.
since 4.3.7

returns a field on all rows in the data set, that is, returns a column in the data set.

Example:

$getVarRows('var1')

Parameters
varName_p name of the variable.
Returns
  • string representation of the value for the variable. If variable contains an array, the array elements will be strung together using semi-colon ";" as the delimeter.

public void gotoState (String gotoStateID_p)

Since: API Level v2

requests next state be set to the state id specified.

Throws
Exception if unknown state

public void gotoTrans (String gotoTransStateID_p, String gotoTransID_p)

Since: API Level v2

requests the transition passed in be performed next.

Throws
Exception if unknown state/transition

public void gotoURL (String url_p)

Since: API Level v2

Set current web page to the url passed in.

It may be used to force current page to be at the specified url on error or failure to reset the page to the correct page for the subsequent sequence to continue.

Example:

<action code="$gotoURL('http://google.com')"/>

Throws
Exception

public String ifElseMsg (String expr_p, String trueMsg_p, String elseMsg_p)

Since: API Level v2

evaluates the expression passed in, if the expression evaluates to true, it returns trueMsg_p expression (may contain other mScript function calls). Otherwise, it returns elseMsg_p.

Example:

$ifElseMsg('[var1] gt 5', 'variable var1 is greater than 5', 'variable var1 is not greater than 5')
Assuming var1 has a value of 6, the above expression returns the message:
variable var1 is greater than 5'

@ifFalseMsg()@chooseMsg()

Returns
  • msg_p if expr_p evaluates to true, else return blank
Throws
Exception
Exception

public String ifFalseMsg (String expr_p, String msg_p)

Since: API Level v2

evaluates the expression passed in, if the expression evaluates to false, it returns the message expression (may contain other mScript function calls). Otherwise, it returns blank.

Example:

$ifFalseMsg('[var1] gt 5', 'variable var1 is greater than 5')
Assuming var1 has a value of 4, the above expression returns the message
variable var1 is greater than 5'

@ifTrueMsg()@chooseMsg()

Returns
  • msg_p if expr_p evaluates to false, else return blank
Throws
Exception
Exception

public String ifTrueMsg (String expr_p, String msg_p)

Since: API Level v2

evaluates the expression passed in, if the expression evaluates to true, it returns the message expression (may contain other mScript function calls). Otherwise, it returns blank.

Example:

$ifTrueMsg('[var1] gt 5', 'variable var1 is greater than 5')
Assuming var1 has a value of 6, the above expression returns the message:
variable var1 is greater than 5'

@ifFalseMsg()@chooseMsg()

Returns
  • msg_p if expr_p evaluates to true, else return blank
Throws
Exception
Exception

public String increment (String varName_p)

Since: API Level v2

increments the variable by 1.

Example:

<action code="$increment('countVar')"/>

Parameters
varName_p variable name
Returns
  • new value
Throws
Exception

public String increment (String varName_p, String delta_p)

Since: API Level v2

increment the variable by the delta passed in.

Example:

<action code="$increment('countVar', '2')"/>
The above expression increments var countVar by 2.

Specify negative number to decrement.

Parameters
delta_p integer
Returns
  • new value
Throws
Exception

public int indexOf (String inputString_p, String subString_p, String startPos_p)

Since: API Level v2

returns the index of first occurrence of the substring specified in the input string starting at the start position specified. Returns -1 if not found. Position returned is 0-based.

This method behaves like java String.indexOf(string, substring, start) where start position is 0-based.

Returns
  • index or -1 if not found
Throws
MBTException

public int indexOf (String inputString_p, String subString_p)

Since: API Level v2

returns the index of first occurrence of the substring specified in the input string. Returns -1 if not found. Position returned is 0-based.

This method behaves like java String.indexOf(string, substring).

Example:

$indexOf('aaaabbb','b')
The above expression returns 4.

Returns
  • index or -1 if not found
Throws
MBTException

public String initCap (String text_p)

Since: API Level v2

capitalize the first char of the text passed in.

Returns
  • string with first char changed to uppercase
Throws
Exception

public boolean isDataSetBegin (String dataSetID_p)

Since: API Level v2

returns true if the dataset is at the first row.

Returns
  • true or false
Throws
Exception
Exception

public boolean isDataSetEnd (String dataSetID_p)

Since: API Level v2

returns true if the dataset is at the last row.

Returns
  • true or false
Throws
Exception
Exception

public boolean isEnvStackEmpty (String varName_p)

Since: API Level v2

return true if stack/queue stored in environment variable is empty.

Returns
  • true or false

public boolean isEnvVarDefined (String varName_p)

Since: API Level v2

returns true if the environment variable specified has been set/defined/initialized. Environment variables are set/initialized/defined using $setEnvVar('varName','value')

public String isEven (String expr)

Since: API Level v2

returns true if the expr represents an even integer, else returns false.

Returns
  • true or false
Throws
Exception

public boolean isFalse (String expr_p)

Since: API Level v2

evaluates the mScript expression and return the negation of the boolean result from the expression. This function is the same as $not(expr)

Example:

$isFalse('[var2]')

Returns
  • true or false
Throws
Exception
Exception
See Also
  • not(expr)

public boolean isModelRunning (String modelName_p)

Since: API Level v2

returns true if the model specified is also running in the same server.

Example:

$isModelRunning('model2')

Parameters
modelName_p name of the model
Returns
  • true or false

public boolean isMultiThread ()

Since: API Level v2

returns true if current model execution is in multi-thread mode.

Returns
  • true or false
Throws
MBTException

public String isOdd (String expr)

Since: API Level v2

returns true if the expr represents an od integer, else returns false.

Returns
  • true or false
Throws
Exception

public boolean isStackEmpty (String varName_p)

Since: API Level v2

return true if stack/queue is empty.

Returns
  • true or false

public boolean isTrue (String expr_p)

Since: API Level v2

evaluates the mScript expression and return true if the result is one of the representation of Boolean true: true, T, 1, yes, Y, etc. All other values are evaluated to false.

Example:

$isTrue('[var2]')

Returns
  • true or false
Throws
Exception
Exception

public boolean isValidDate (String dateString_p)

Since: API Level v2

returns true if the date string passed in can be parsed by the default date format.

Parameters
dateString_p date string
Returns
  • true/false
Throws
Exception

public boolean isVarDefined (String varName_p)

Since: API Level v2

returns true if the user variable specified has been set/defined/initialized. User variables are set/initialized/defined using $setVar('varName','value')

public String listFuncParams ()

Since: API Level v2

returns a string that represent parameters. Used to print out the parameters passed to the current user function for debugging or auditing.

Example:

$listFuncParams()

Returns
  • text representation of all parameters passed to the function
Throws
Exception
Exception

public void loadFromDataSource (String... dsParams_p)

Since: API Level v2

loads the data set from the data source defined with or without parameter. The use of parameter(s) is typically used in sql data source which you have defined a sql query parameter with ?. Parameters are used by position, that is, the first paramter provided will be used to replace/set the first ? in the sql statement.

Examples:

<action code="$loadFromDataSource('myDS')"/> 
<action code="$loadFromDataSource('myDS', 'p1')"/>

Throws
Exception on any error

public void log (String level_p, String msg_p)

Since: API Level v2

writes to MScript log file with specified log level.

Parameters
level_p info, error, debug. Default info
msg_p log message

public void log (String msg_p)

Since: API Level v2

writes to MScript log file.

Parameters
msg_p log message

public String mod (String expr1_p, String expr2_p)

Since: API Level v2

performs modulo operation expr1_p % expr2_p and returns the remainder.

Example:

$mod('23','2')
The above expression returns "1".

Returns
  • result
Throws
Exception

public String multiply (String expr1, String expr2)

Since: API Level v2

multiply two exprs.

Example:

<action code="$multiply('$getVar('a')', '2')"/>

Returns
  • result value
Throws
Exception

public boolean nand (String... exprList_p)

Since: API Level v2

performs NAND on the expression list passed. blank exprs are ignored.

Parameters
exprList_p list of expressions, each expression in a separate parameter.
Returns
  • true/false
Throws
Exception
See Also
  • and(String ...)

public String negate (String exprList_p)

Since: API Level v2

perform the negation operation on the result from the expression passed in.

Example:

$substract('[var1]')
Assuming var1=20, this above script returns -20, but it does not change var1.

Returns
  • result value
Throws
Exception

public int nextDataSetRow (String dataSetID_p, String floatIdx_p)

Since: API Level v2

moves the data set to a row randomly selected.

Example:

$nextDataSetRow('ds1', '0.5')
The above expression will attempt to set to a row in the middle of the data set. On any error, it will set the data set to the next row.

Parameters
dataSetID_p data set id
floatIdx_p a random float number between 0 and 1, use 0 for first row, 1.0 for last row, 0.5 for the middle row in the data set.
Throws
MBTException

public int nextDataSetRow (String dataSetID_p)

Since: API Level v2

moves data set to next row. If data set is defined to auto rewind, it will reset to first row when it reaches end of the list. Otherwise, it will stay at the last row when it reaches the end of the list.

Example:

<action code="$nextDataSetRow('myDS')"/>

Parameters
dataSetID_p data set id
Returns
  • new row number for the data set
Throws
MBTException

public int nextVarRow (String varName_p)

Since: API Level v2

This method is deprecated.
since 4.3.7

Advances the variable current row number by 1. Returns 0 if the end is reached.@return

public void noOut (String msg_p)

Since: API Level v2

forces not to generate any output. This is used to supress output from other mscript method calls.

Example:

<log msg="Failed. $noOut('$snapScreen()')"/>
In the above example, $snapScreen() returns the name of the snapscreen file which is then passed to $noOut(). As the result the above mScript just logs the message "Failed. " to the mScript log file without the snapscreen file name returned by $snapScreen().

public boolean nor (String... exprList_p)

Since: API Level v2

performs NOR on the expression list passed. blank exprs are ignored.

Parameters
exprList_p list of expressions, each expression in a separate parameter.
Returns
  • true/false
Throws
Exception
See Also
  • and(String ...)
  • xor(String ...)

public boolean not (String expr_p)

Since: API Level v2

evaluates the mScript expression and return the negation of the boolean result from the expression. This function is the same as $isFalse(expr).

Example:

$not('[var2] eq $getData('ds1','f1')')

Returns
  • true or false
Throws
Exception
Exception
See Also
  • ifFalse(expr)

public boolean or (String... exprList_p)

Since: API Level v2

performs OR operation on the two mScript expressions passed in and returns a true if any of the expressions evaluates to true, else return false.

Example:

$or('[seqNum] eq 1', '[seqNum] gt 10')
The above expression returns true when seqNum var is either 1 or greater than 10.

Parameters
exprList_p list of expressions, each expression in a separate parameter.
Returns
  • true/false
Throws
Exception
Exception
See Also
  • and(String ...)

public String osCmd (String cmd_p)

Since: API Level v2

osCmd: runs an os command. You must have admin priv on your computer (running this server). Running without admin priv may cause $osCmd() to hang or timeout.

Alternatively, use osCmdAsynch() which returns the control back to the model immediately.

A typical use might be to call OS email utility to send email or run a batch file or shell script to perform certain action. Note this method does not return a result. Use space to separate command parameters. Each parameter (command argument) and file path can not have spaces in them. If the parameter/argument contains spaces, you must encode the space with [space].

Use this command to run an external application or scripts that will complete right away. If the application will stay up, use $osCmdAsynch() instead.

Example:

<log msg="Running myTest.bat, output is: $osCmd('c:/temp/myTest.bat')"/>

Parameters
cmd_p os command with arguments separated by "^".
Returns
  • output from the os command
Throws
Exception
See Also
  • osCmdAsynch()

public String osCmd (String cmd_p, String killAfterMillis_p)

Since: API Level v2

osCmd: runs an os command, waits for the specified milliseconds and stops the application.

A typical use might be to call OS perform an operation using os command or custom application (exe).

Example:

<log msg="Running myApp.bat, output is: $osCmd('c:/myTest.bat','5000')"/>

Some os command may require certain authorization set appropriately due to security reason. For example to run PowerShell script, you will need to set ExecutionPolicy to Unrestricted to allow powerscript to be executed from the application. You may also need to set ExecutionPolicy Bypass so that it does not prompt you to say if it's ok to run the script.

Parameters
cmd_p os command string, use "^" to separate multiple arguments.
Returns
  • output from the os command

public String osCmd (String cmd_p, String killAfterMillis_p, String logFileName_p)

Since: API Level v2

osCmd: runs an os command, waits for the specified milliseconds and stops the application.

A typical use might be to call OS perform an operation using os command or custom application (exe).

Example:

<log msg="Running myApp.bat, output is: $osCmd('c:/myTest.bat','5000', 'out.log')"/>

Parameters
cmd_p os command string, use "^" to separate multiple arguments.
logFileName_p absolute file path to store output / error from the os command
Returns
  • output from the os command

public String osCmdAsynch (String cmd_p, String logFileName_p)

Since: API Level v2

osCmd: runs an os command asynchronously.

A typical use might be to call OS email utility to send email or run a batch file or shell script to perform certain action. Note this method does not return a result.

Example:

<action code="$osCmdAsynch('c:/myapp.exe')"/>

Parameters
logFileName_p absolute log file path to store the output and error from the os command
Returns
  • error message if submission of the command is successful. null/blank for successful submission of command to run in asynch mode.
See Also
  • osCmd()

public String osCmdAsynch (String cmd_p)

Since: API Level v2

osCmd: runs an os command asynchronously.

A typical use might be to call OS email utility to send email or run a batch file or shell script to perform certain action. Note this method does not return a result.

Example:

<action code="$osCmdAsynch('c:/myapp.exe')"/>

Returns
  • error message if submission of the command is successful. null/blank for successful submission of command to run in asynch mode.
See Also
  • osCmd()

public void pauseNext ()

Since: API Level v2

to request execution to be paused at the next pauseable position: mscript line or next traversal of state or transition.

Example: Call this method in OnException or OnError triggers or anywhere in mScript to request the model execution be paused upon any exception or error or a certain condition evaluates to true (inside a if tag).

Be aware that calling this method will cause the mode execution to be paused indefinitely until the model is stopped or server is shut down. So, this method should only be used for interactive model execution which a person is watching or will be checking at the later time and take action when the model is paused.

Example:

$pauseNext()

public String peek (String varName_p)

Since: API Level v2

peeks the last value in stack without pop it. Stack is consistent with java stack implementation: First-In, Last Out (FILO).

Example:

$peek('myStack')
The above expression retrieves the last value in the stack but does not pop the last value out of the stack.

Parameters
varName_p name of the variable.
Returns
  • the value last pushed into the stack or blank if stack is empty.
Throws
Exception on inconsistent use of the stack variable, for example the variable was previously used as a single variable.
MBTException

public String peekAt (String varName_p, String atIdx_p)

Since: API Level v2

peeks at the element at the specified position/index. First (oldest) element is at 0.

Stack is consistent with java stack implementation: First-In, Last Out (FILO).

Returns blank if stack variable is empty.

if index specified is less than 0 return the first element.

if index specified is over the size of the stack or not a valid integer, return the last element

Returns
  • variable value
Throws
MBTException

public String pop (String varName_p)

Since: API Level v2

pops the last value from stack. Stack is consistent with java stack implementation: First-In, Last Out (FILO).

Example:

$pop('myStack')

Parameters
varName_p name of the stack variable.
Returns
  • variable value
Throws
Exception on inconsistent use of the stack variable, for example the variable was previously used as a single variable.
MBTException

public void popAll (String varName_p)

Since: API Level v2

clears the stack.

public String popAt (String varName_p, String atIdx_p)

Since: API Level v2

Remove an element at the specified position from the stack described by the variable name.

Stack is consistent with java stack implementation: First-In, Last Out (FILO).

First (oldest) element is at 0.

It returns the index position of the element removed.

If the stack is empty, return -1.

If index specified is less than 0, the first element will be removed and 0 is returned.

If index specified is greater than stack size or invalid index supplied, the last element will be removed.

Returns
  • value removed from the stack
Throws
MBTException
MBTException
See Also

public int previousDataSetRow (String dataSetID_p)

Since: API Level v2

moves data set to previous row. If data set is defined to auto rewind, it will reset to last row when it reaches beginning of the list. Otherwise, it will stay at the first row when it reaches the beginging of the list.

Example:

<action code="$previousDataSetRow('myDS')"/>

Parameters
dataSetID_p data set id
Returns
  • new row number for the data set
Throws
MBTException

public void push (String varName_p, String value_p)

Since: API Level v2

push a value into a stack variable. Stack is consistent with java stack implementation: First-In, Last Out (FILO).

Example:

$push('myStack', 'xx')
The above expression will push 'xx' to the end of list of values for 'myStack'. You will then use "$pop('myStack')" to retrieve the last value in the stack.

Parameters
varName_p name of the variable.
value_p value to be pushed to the stack.
Throws
Exception if the inconsitent use of the variable. That is, if the variable was previous used as a single string variable.
MBTException

public int pushAt (String varName_p, String atIdx_p, String value_p)

Since: API Level v2

Insert the value/element into the stack described by varName_p at the speified position (atIdx_p).

Stack is consistent with java stack implementation: First-In, Last Out (FILO).

If the position specified is outside the stack size, it inserts the element to the beginning of the list if the index is < 0 and end of the list if index specified is too big or not an integer.

First (oldest) element is at 0.

Parameters
varName_p stack variable name
atIdx_p index position where the element will be inserted at. 0 as the first element.
value_p value/element to be inserted into the stack
Returns
  • position /index where the element is inserted
Throws
MBTException

public void raiseException (String level_p, String failedMsg_p)

Since: API Level v2

raises an exception with the specified exception level.

Throws
Exception

public int rand (String startInt_p, String endInt_p)

Since: API Level v2

returns a random integer number between startInt_p (inclusive) and endInt_p (exclusive).

Example:

$rand('2', '5')
The above expression will return a random integer of 2, 3, or 4.

Parameters
startInt_p min value inclusive
endInt_p max value exlusive
Returns
  • random number
Throws
Exception

public String rand (String startNum_p, String endNum_p, String precisionDigit_p)

Since: API Level v2

returns a random integer number between startInt_p (inclusive) and endInt_p (exclusive).

Example:

  • $rand('2','5','0') to return a random integer of 2, 3, or 4.
  • $rand('2','5','2') to return a random float number with two digits to the right of the decimal point, like 3.15.

Parameters
precisionDigit_p number of significant digit after decimal point. 0 for integer.
Returns
  • random string
Throws
Exception

public int rand (String limit_p)

Since: API Level v2

returns a random integer number between 0 (inclusive) and limit_p (exclusive).

Example:

$rand('10')

Parameters
limit_p upper limit (excluded)
Returns
  • random number
Throws
Exception

public float rand ()

Since: API Level v2

returns a random number in float between 0 (inclusive) and 1 (exclusive).

Returns
  • random number
Throws
Exception

public boolean randBool (String trueProb_p)

Since: API Level v2

returns a randomly chosen true or false with the true probability.

Example:

$randBool ('0.75')
The above expression will generate a random boolean value with 75% chance of being true and 25% chance of being false.

Parameters
trueProb_p probably between 0 and 1 to generate true value.
Returns
  • true or false
Throws
Exception
Exception

public boolean randBool ()

Since: API Level v2

returns a randomly chosen true or false.

Returns
  • true or false with equal probability.
Throws
Exception
Exception

public Integer removeDataRow (String dataSetID_p, String fieldNames_p, String compValues_p)

Since: API Level v2

removes rows from dataset that meet the specified criteria. It does not delete the records from the underlying file. It just removes the data rows from the dataset stored in the memory. Criteria are described with field name and the matching field value.

Example:

$removeDataRows ('myDS', 'F1;F2', 'val1;val2')

In the above example, rows are removed from myDS dataset which have val1 in field F1 and val2 in field F2.

Parameters
dataSetID_p dataset id
fieldNames_p list of field names separated by semi-colon
compValues_p list of field values separated by semi-colon, must have one-to-one matching with fieldNames_p.
Returns
  • number of rows deleted
Throws
MBTException

public Integer removeDataRowExcept (String dataSetID_p, String fieldNames_p, String compValues_p)

Since: API Level v2

removes rows from dataset that do not meet the specified criteria. It does not delete the records from the underlying file. It just removes the data rows from the dataset stored in the memory. Criteria are described with field name and the matching field value. See example below.

Example:

$removeDataRows ('myDS', 'F1;F2', 'val1;val2')

In the above example, rows are removed from myDS dataset which have val1 in field F1 and val2 in field F2.

Parameters
dataSetID_p dataset id
fieldNames_p list of field names separated by semi-colon
compValues_p list of field values separated by semi-colon, must have one-to-one matching with fieldNames_p.
Returns
  • number of rows deleted
Throws
MBTException

public String replace (String inputString_p, String subString_p, String newString_p)

Since: API Level v2

perform string replacement.

Parameters
inputString_p original string
subString_p substring to be replaced with newString_p. If subString_p starts with "/" and ends with "/", regular expression will be used to to perform the replacement after removing the "/".
newString_p new substring to replace subString_p
Returns
  • return string
Throws
MBTException

public void requires (String libModelName_p)

Since: API Level v2

imports external user functions into current model execution.

Example:

$requires('MyFuncModel1')

The user functions included through this mscript can then be called with $callFunc('myFunc2', 'p1', 'p2', ...)

Parameters
libModelName_p name of the model that contains the user functions to be imported.
Throws
Exception if model does not exist or model contains no user functions.

public void requires (String libModelName_p, String libID_p)

Since: API Level v2

imports external user functions into current model execution with a prefix library id. All functions imported by this statement must be called with the library id prefix, e.g. $callFunc('libA.funcA', 'p1').

Example:

$requires('MyFuncModel1', 'libA')

The user functions included through this mscript can then be called with $callFunc('libA.myFunc2', 'p1', 'p2', ...)

Parameters
libModelName_p name of the model that contains the user functions to be imported.
Throws
Exception if model does not exist or model contains no user functions.

public void resetSeqNum ()

Since: API Level v2

resets the seqNum sys var to 0.

public String resolveUIMap (String uiMap_p)

Since: API Level v2

resolve UIMap path passed in and return the actual locator that would be passed to Selenium plugin for performing action. If the return locator contains single quote, it will be escaped so that the return value may be used in MScript expression as shwon in the example below.

Example:

$setVar('actualLoc', '$resolveUIMap('map=mybtn')')

Parameters
uiMap_p uiMap locator, must starts with map=
Returns
  • Selenium locator string
Throws
MBTException

public void rewindDataSet (String dataSetID_p)

Since: API Level v2

reset the data set to start at the first row.

Example:

<action code="$rewindDataSet('myDS')"/>

Parameters
dataSetID_p data set id

public int rewindVar (String varName_p)

Since: API Level v2

This method is deprecated.
since 4.3.7

sets the current row number for the variable to 0. If variable does not exist or the value list is empty, it return -1.

Example:

$rewindVar('var1')
The above exression will rewind the variable 'var1' if it has been set to contain array.

public int saveStats (String statDesc_p)

Since: API Level v2

saves current execution stats to db and return the execID. Should only call this function in MBT_end trigger as stats can only be saved once.

If the model is called remotely using $runModel() with LoadPlugin, the model stats is automatically saved and thus no need to call this function or it does no-op if called repeatedly.

Example:

$saveStats('execution 2011-11-02')

Parameters
statDesc_p stat description to be saved with the stats.
Returns
  • stat execID
Throws
Exception

public Integer searchData (String... searchParams_p)

Since: API Level v2

searches for the data row that match the condition specified and return the count of rows matching the criteria and moves data set to the first matched row. search conditions specified are "AND" together. You can specify one condition on one field per search condition.

The searchCondition must be an MScript expression that evaluates to true or false using the format of 'fieldName' 'operator' 'searchPattern' where fieldName must be a valid field name within the specified dataset.

The operator can be one of the following (same as the op in AssertTag):

  • gt - greater than
  • lt - less than
  • ge - greater than or equal to
  • le - less than or equal to
  • eq - equal to
  • ne - not equal to
  • in - matching one of the values separated by comma (,)
  • between - between two numbers separated by comma (,) or and
  • contains - containing the text
  • startsWith - starting with (prefix) of a text
  • endsWith - ending with (suffix) of a text
  • match - matching regular expression
  • soundsLike - matching soundex
  • spellsLike - less than 10% different in chars
  • NOTin - not in one of the values separated by comma (,)
  • NOTbetween - not between two numbers separated by comma (,) or and
  • NOTcontains - not containing the text
  • NOTstartsWith - not starting with the text
  • NOTendsWith - not ending with the text
  • NOTmatch - not matching the regular expression specified
  • NOTsoundsLike - not matching soundex specified
  • NOTspellsLike - having over 15% different in chars

Example:

<action log="# of DEPOSIT with deposit amount less than $5000: $searchData('ds1','PaymentType eq DEPOSIT', 'Amount lt 5000')"/>

Returns
  • count of matches
Throws
MBTException
Exception
See Also
  • searchDataRowIndex()

public Integer searchDataRowIndex (String... searchParams_p)

Since: API Level v2

searches for the data row that match the condition specified and return the count of rows matching the criteria and moves data set to the first matched row. search conditions specified are "AND" together. You can specify one condition on one field per search condition.

The searchCondition must be an MScript expression that evaluates to true or false using the format of 'fieldName' 'operator' 'searchPattern' where fieldName must be a valid field name within the specified dataset.

See $searchData() for a list of operators available.

Example:

<action log="Row index of first row with deposit amount less than $5000: $searchData('ds1','PaymentType eq DEPOSIT', 'Amount lt 5000')"/>

Returns
  • row indx of first matched row
Throws
MBTException
Exception
See Also
  • searchData()

public void sendMail (String fromAddress, String toAddress, String subject, String messageText)

Since: API Level v2

send mail. Requires javaMail setup in system config (smtp mail host).

Parameters
fromAddress from address, if blank passed, it will use the license email address
toAddress to address
subject subject text
messageText message body text
Throws
MBTException
MBTException

public void sendMail (String toAddress, String subject, String messageText)

Since: API Level v2

send mail. Requires javaMail setup in system config (smtp mail host).

Parameters
toAddress to address
subject subject text
messageText message body text
Throws
MBTException
MBTException

public synchronized void seqout (String seqText_p)

Since: API Level v2

writes a message to seq.out (SeqOut) file in the model folder. This is an alternative to <seqout> tag.

Example:

$seqout('myVar = [quot][curStateID][quot]')
The above expression will write the following to seq.out:
myVar = "LoginPage"
if the current state id is at "LoginPage".

The alternative is to use <seqout> tag as follows to generate the same output in seq.out:

 <seqout>
 	 <output>
     myVar = "[curStateID]"
   </output>
</seqout>

Parameters
seqText_p text to be written to seq.out
Throws
Exception on any i/o error

public void setAppURL (String appURL_p)

Since: API Level v2

sets AUT App/URL. Call this in MBT_Start trigger to change AUT application path / URL for the execution.

Example:

<action code="$setAppURL('http://prod.mySvr.com')"/>

public void setCurTransGuardHint (String hint_p)

Since: API Level v2

change the transition's guard hint at runtime. The guard hint and satisfying hint work together. A transition with the matching satisfying hint will satisfy the guard of the transition when traversed.

Guard hint is a code (or codes separated by comma).

Example:

$setCurTransGuardHint('Login')

The above example sets the guard hint on the current transition to Login. When traversing this transition but the guard fails, the sequencer will attempt to find the transitions with the satisfying hint that matches the guard hint.

The assumption is that when the transition with the matching satisfying hint is traversed, it will make the guard condition to true and this this transition can be traverse next.

Throws
Exception
Exception

public void setCurTransSatisfyingHint (String hint_p)

Since: API Level v2

change the transition's satisfying hint at runtime. The guard hint and satisfying hint work together. A transition with the matching satisfying hint will satisfy the guard of the transition when traversed.

Satisfying hint is a code (or codes separated by comma).

Example:

$setCurTransSatisfyingHint('Login')

The above example sets the satisfying hint on the current transition to Login.

Throws
Exception
Exception

public boolean setData (String dataSetID_p, String fieldName_p, String value_p)

Since: API Level v2

changes a field in the data set. Only the value in the memory is changed.

Example:

$setData('ds1', 'f1', 'newVal')

Parameters
dataSetID_p data set id
fieldName_p field name
value_p new value for the field
Returns
  • true if set was performed successfully, else false. For example if an invalid data set id was used, it will return false as it could not find the data set.
Throws
MBTException

public void setDataSetRow (String dataSetID_p, String rowIdx_p)

Since: API Level v2

moves the data set to a row specified.

Example:

$setDataSetRow('ds1', '2')
The above expression will attempt to set to the 3rd row in the data set.

Parameters
dataSetID_p data set id
Throws
MBTAbort

public void setDateFormatLocale (String dateFormat_p, String dateTimeFormat_p, String locale_p)

Since: API Level v2

sets the default date format and locale. This will be the date format to be used to parse the date by $isValidDate(dateString) and datePart() functions.@return

Parameters
dateFormat_p java date format, e.g. MM/dd/yyyy
locale_p An ISO 639 alpha-2 or alpha-3 language code, or a language subtag up to 8 characters in length. See the Locale class description about valid language values.
Throws
Exception

public void setEnvVar (String varName_p, String toValue_p)

Since: API Level v2

Set environment variable to the specified value.

Example:

<action code="$setEnvVar('myVar','123')"/>

Parameters
varName_p variable name
toValue_p new value
Throws
Exception

public void setFuncReturn (String retVal_p)

Since: API Level v2

sets the return value for the current user function.

Example:

$setFuncReturn('returnResult')

Parameters
retVal_p return value
Throws
Exception
Exception

public void setMaxTraverseTimes (String stateID_p, String transID_p, String maxTraverseTimes_p)

Since: API Level v2

sets the maximum number of traversal for the specified transition.

By default all transitions can be traversed infinite number of times. At times you may wish to limit certain transitions not be traversed above a specific number.

Use this function to dynamically change the number of times you want to limit the number of times the transition can be traversed. Note this function is only available with the Random sequencer or Greedy sequencer. It will cause error if used with other sequencers.

Example:

$setMaxTraverseTimes('state1','trans1','5')

Be aware that changing the maximum number of traversed for the transition may affect when the model execution will stop and also cause model execution to loop if additional traversal of this transition is required to complete the model execution to meet the desired test coverage.

Parameters
stateID_p name of the state
transID_p name of the transition within the stateID_p
maxTraverseTimes_p 0 or positive integer.
Throws
MBTException
Exception

public void setMinTraverseTimes (String stateID_p, String transID_p, String minTraverseTimes_p)

Since: API Level v2

sets the minimum number of traversal required for the specified transition.

Use this function to dynamically change the number of times you want to see transition traversed. Note this function is only available with the Random sequencer or Greedy sequencer. It will cause error if used with other sequencers.

Example:

$setMinTraverseTimes('state1','trans1','5')

Be aware that changing the minimal number of traversed required for the transition may affect when the model execution will stop.

Parameters
stateID_p name of the state
transID_p name of the transition within the stateID_p
minTraverseTimes_p 0 or positive integer.
Throws
MBTException
Exception

public void setNextMCase (String MCaseName_p)

Since: API Level v2

sets the next mcase to be executed by the next submodel that has mcase implementation.

call this method as close as possible to the submodel which is expected to use this mcase setting as this setting is visible to all submodels. It will be reset to null after it's used by any submodel.

Throws
Exception
Exception
See Also
  • getNextMCase()

public void setPathVar (String varName_p, String varVal_p)

Since: API Level v2

sets a specific traversal path variable to the value passed in. Traversal vars are carried over along the traversal path. Duplicate variables are merged by randomly choosing a value from the multiple traversal paths being merged.

Example:

$setPathVar('msgTriggerred','packet1')

Throws
MBTException

public void setRecordingInerval (String millis)

Since: API Level v2

change the screen recording interval. This overrides the default (200 ms) and the customized setting recording.interval.millis in /config/config.properties.

Parameters
millis - number of milliseconds

public boolean setSeed (String seed_p)

Since: API Level v2

initialize random number generator used by the sequencer to the speific seed. By default system uses the default seed for the random number generator. Changing the random number generator seed will affect the actual test sequence generated while maintaining the same test coverage of the model. At times you may wish to try different seed just to get a different variation from the test sequence generated with the default seed.

This function is usually called in the MBT_start trigger. However you may call it anywhere in MScript.@return

public void setSeqNum (String seqNum_p)

Since: API Level v2

sets sys var seqNum to the value specified.

Example:

$setSeqNum('10')
The above expression sets the sequence number to 10.

public void setSeqOutFile (String fileName_p)

Since: API Level v2

sets the sequence output file. Sequence output file is used by <seqout> tag to write the sequence output for offline testing. For example you may use to generate java code, javascript or vba script. The output file will be written to report folder, replacing the existing file if one exists.

You may use variable in the file name parameter to ensure a different file name is used for each execution.

This method must be called before the first <seqout> tag, usually in MBT_start trigger.

Do not use this method with SeqOut plugins! Calling this function with non blank fileName_p automatically enables comment to seqout.

Example:

$setSeqOutFile('out.java')

Parameters
fileName_p file name only, do include the folder path.
Throws
MBTException
See Also
  • enableCommentToSeqOut(), disableCommentToSeqOut()

public void setStateResetURL (String stateID_p, String resetURL_p)

Since: API Level v2

sets resetURL for the specified state.

Example:

<action code="$setStateResetURL('state_1', 'http://prod.mySvr.com/abc')"/>

Parameters
stateID_p state id to set the resetURL for
resetURL_p new url
Throws
Exception

public void setTravVar (String varName_p, String val_p)

Since: API Level v2

sets the value for the traversal variables. Traversal variables are valid within the scope of the transition / state traversal.

See Also
  • getTravVar(String)

public boolean setVar (String varName_p, String toValue_p)

Since: API Level v2

Set user variable to the specified value. returns true if value has changed. It triggers the varChangeListener if value has been changed.

Example:

<action code="$setVar('myVar','123')"/>

Parameters
varName_p variable name
toValue_p new value
Returns
  • true if the var is set to the value passed in. False if no change.
Throws
the variable has a change listener defined and it errored in the listener.
Exception

public boolean setVar (String varName_p, String toValue_p, String modelName_p)

Since: API Level v2

Sets a variable on a different model execution. If multiple threads were running the specified model, it chooses the first thread to set the variable. The model must be running in the same TO server.

This function requires multiple user session license

Example:

$setVar('var2','xyz','Model2')

Returns
  • true if var is set successfully, false if the var could not be set due to model not running or any other error.
Throws
MBTException

public void setVarRowNum (String varName_p, String rowNum_p)

Since: API Level v2

This method is deprecated.
since 4.3.7

Sets the current row number (subscript) for mbt variable passed in. If index number passed in is not value (less than 0 or greater than the array size), this method returns without performing the request.

Parameters
varName_p variable name
rowNum_p row number 0-based.
Throws
MBTException

public void setVarsFromDataSet (String dataSetID_p, String varPrefix_p)

Since: API Level v2

create/set user variable for each column in the current row of the dataset. User variables are named with the supplied prefix to the column name.

Parameters
dataSetID_p name of the data set
varPrefix_p prefix to be pre-pended to the column name to form the user variable name
Throws
Exception
Exception

public void sleep (String millis_p)

Since: API Level v2

sleeps for number of milliseconds.

Throws
Exception

public List<String> snapScreen ()

Since: API Level v2

To cause a snapshot of current screen of each AUT by calling each plugins enabled for the model execution. The output file type depends on the plugin being used. If multiple plugins enabled that supports snapScreen(), image files are separated by semi-colon. Selenium takes an image of the screen in jpg while HtmlUnit takes a copy of html source file.

Typical use of this method is to call it in or trigger to take a snapshot of the screen of the error.

The screen shot will be marked with the first exception (if multiple exceptions) triggered by current mScript and thus available from the exception popup.

Example:

<action code="$snapScreen()"/>

If multiple plugins are enabled and you wish to take a snapScreen of the specific AUT being automated by the plugin, you can accomplish so by calling $snapScreen(...) of the specific plugin by prefixing the method name, e.g. $WinUIA.snapScreen(...).

Returns
  • file path for the screen shot file
Throws
Exception
See Also

public List<String> snapScreen (String fileName_p)

Since: API Level v2

To cause a snapshot of current screen of each AUT by calling each plugins enabled for the model execution. The output file type depends on the plugin being used. If multiple plugins enabled that supports snapScreen(), image files are separated by semi-colon. Selenium takes an image of the screen in jpg while HtmlUnit takes a copy of html source file.

Typical use of this method is to call it in or trigger to take a snapshot of the screen of the error.

The screen shot will be marked with the first exception (if multiple exceptions) triggered by current mScript and thus available from the exception popup.

Example:

<action code="$snapScreen('myFileName')"/>

If multiple plugins are enabled and you wish to take a snapScreen of the specific AUT being automated by the plugin, you can accomplish so by calling $snapScreen(...) of the specific plugin by prefixing the method name, e.g. $WinUIA.snapScreen(...).

Parameters
fileName_p name of the file, final file name will suffixed with "_timestamp".
Returns
  • file path of the screen shot file
Throws
Exception
See Also

public boolean soundAlike (String string1_p, String string2_p)

Since: API Level v2

returns true if two strings sound like each other.

Example:

$soundAlike ('behavior','behaviour')

Returns
  • true if two strings sound like the same, else false
Throws
Exception
Exception

public boolean soundAlike (String string1_p, String string2_p, String conf_p)

Since: API Level v2

returns true if two strings sound alike with the degree of similarity specified.

Example:

$soundAlike ('behavior','behaviour', '4')

Parameters
conf_p between 0 and 4 with 0 match anything, 4 being sound exactly the same. invalid value is defaulted to 4 (exactly sound like)
Returns
  • true if two strings sound like the same with the conf_p specified, else false
Throws
Exception
Exception

public boolean spellAlike (String string1_p, String string2_p, String conf_p)

Since: API Level v2

returns true if two strings are spelled alike with up to specified degree of differences allowed.

Example:

$spellAlike('collaboration', 'collaberaton', '1')
$spellAlike('collaboration', 'collaberaon', '0.1')

Parameters
string1_p original string
string2_p string to compare to
conf_p max number of chars difference between the two strings (edit distance) allowed or fraction of the number of chars of the shorter string. For example 2 for maximum of 2 chars diff allowed and 0.10 for 10% of the length of the shorter string rounded up.
Returns
  • true if the difference of the two strings spell alike according to the degree of difference specified, false otherwise.
Throws
Exception
Exception

public boolean spellAlike (String string1_p, String string2_p)

Since: API Level v2

returns true if two strings are spelled alike with up to specified degree of differences allowed. Two strings are considered spell alike if the number of chars in difference is less than 15% of max string length of thw two strings.

Example:

$spellAlike('collaboration', 'collaberaton')

Parameters
string1_p original string
string2_p string to compare to
Returns
  • true if the difference of the two strings spell alike according to the degree of difference specified, false otherwise.
Throws
Exception
Exception

public String splitPiece (String inputString_p, String delimeter_p, String index_p)

Since: API Level v2

returns nth piece of the input string split by the delimiter specified. The delimiter can be either a regular expression or a text string. If calling with a text string as the delimiter, any special characters used by regular expression must be escapped appropriately based on regular expression rule.

Returns
  • the piece at the index poistion specified
Throws
MBTException

public int stackSize (String varName_p)

Since: API Level v2

returns the count of elements currently in the stack/queue.

Returns
  • stack size

public void startScreenRecording (String recordingSetName)

Since: API Level v2

starts screen recording and save the recording to the name specified. A subfolder is created with the named specified in /video/ folder to store the recorded screenshot files. If subfolder already exists, previously stored screenshot files will be deleted automatically. You may move default location of /video/ to another disk. By default, it takes a screenshot of the window every 200 milliseconds. You may override this setting by changing recording.interval.millis in /www/MbtSvr/config/config.properties file. The system automatically removes the screenshots that have not changed since the previous screenshot. You can playback the screen recording using "File/Playback" menu. Note that sreen recording will consume CPU, disk I/O and disk space. As the result, it may affect the performance of your automation scripts.

Throws
Exception

public void stopScreenRecording ()

Since: API Level v2

stop screen recording.

Throws
Exception

public int stringLength (String inStr)

Since: API Level v2

Returns the length of the string passed in.

public String substract (String expr1_p, String expr2_p)

Since: API Level v2

performs the substraction operation: expr1 - expr2.

Example:

$substract('[var1]','100')
If var1=250, the above expression will return 150. Note this operation does not change var1.

Returns
  • result value
Throws
Exception

public String substring (String inputString_p, String startPos_p)

Since: API Level v2

returns a substring of the input string starting at the position specified (inclusive) to the end of the string.

This method behaves like java String.substring(string, start) where start position is 0-based.

Example:

$substring('aaaabbb','1')
The above expression returns aaabbb (truncating the first char).

Returns
  • substring
Throws
MBTException

public String substring (String inputString_p, String startPos_p, String endPos_p)

Since: API Level v2

returns a substring of the input string between the start (inclusive) and end (exclusive) positions specified.

This method behaves like java String.substring(string, start, end) where start and end positions are 0-based. .

Example:

$substring('aaaabbb','1', '5')
The above expression returns aaab.

Returns
  • substring
Throws
MBTException

public String time (String timeExpr_p)

Since: API Level v2

returns time in a string in the format specified in the default date/time format as set by $setDateFormatLocale (defaulted to MM/dd/yyyy HH:mm). Supports several variation of time expression: +1H, -1H, -10M, +10M for relative time from now, as well as '' or 'now' for time now.

For example "$time('+1H')" will return time 1 hour from now.

Parameters
timeExpr_p time expression as described above.
Returns
  • time string
Throws
MBTException

public String time (String timeExpr_p, String timeFmt_p)

Since: API Level v2

returns a time string in java date/time format specified. Supports several variation of time expression: +1H, -1H, -10M, +10M.

Parameters
timeExpr_p time expression as described above.
timeFmt_p date/time format to be used to format the date/time into string. Accept java date simple date format, for example "MM/dd/yyyy hh:mm:ss". You may also use "epoch" as the format string to retrieve date in number of milliseconds since Jan. 1, 1970 (epoch time).
Returns
  • time string
Throws
MBTException
See Also
  • http://download.oracle.com/javase/6/docs/api/java/text/SimpleDateFormat.html

public String time ()

Since: API Level v2

returns current time in string in standard time format MM/dd/yyyy HH:mm.

Returns
  • time string
Throws
MBTException

public String toLowerCase (String text_p)

Since: API Level v2

converts to lowercase.

Parameters
text_p - input text string
Returns
  • text string in lowercase
Throws
Exception

public String toUpperCase (String text_p)

Since: API Level v2

converts to uppercase.

Parameters
text_p - input text string
Returns
  • text string in uppercase
Throws
Exception

public String trace (String maxLogCount_p)

Since: API Level v2

returns the trace in a string of last maxLogCount_p traversals leading up to the current state/transition.

Example: place in onException or onError in <log> tag to print out trace of what sequence of states and transitions that led to the current state/transition where the error/failure occurred.

Parameters
maxLogCount_p max number of traversals
Returns
  • String, example output as follows 'type' 'id'.

    State Checkout
    Transition ContinueShopping
    State ProductList

Throws
Exception
Exception

public String trace ()

Since: API Level v2

returns the trace in a string of the traversals from the initial state to leading up to the current state/transition.

Example: place in onException or onError in <log> tag to print out trace of what sequence of states and transitions that led to the current state/transition where the error/failure occurred.

Returns
  • String, example output as follows (timestamp: type state/trans id(uid: #)):

    06:09:57.609:State Checkout(uid:104)
    06:09:57.609:Transition ContinueShopping(uid:115)
    06:09:57.656:State ProductList(uid:101)

Throws
Exception
Exception

public String trace (String maxLogCount_p, String delimiter_p)

Since: API Level v2

returns the trace in a string of last maxLogCount_p traversals leading up to the current state/transition. Trace sequence is separated by the specified delimiter.

Example: place in onException or onError in <log> tag to print out trace of what sequence of states and transitions that led to the current state/transition where the error/failure occurred.

Example:

$trace('5','<br/>')

Parameters
maxLogCount_p max number of traversals
delimiter_p delimiter to be used to separate the traversals.
Returns
  • String, example output as follows 'type' 'id'.

    State Checkout
    Transition ContinueShopping
    State ProductList

Throws
Exception
Exception

public String trim (String text_p)

Since: API Level v2

trims the leading and trailing space/blank characters from the text string.

Returns
  • text with leading and trailing space/blank characters removed.

public String[] twitterGet (String user_p)

Since: API Level v2

retrieves status update/message from the pre-configured twitter account.

Requires twitter to be configured, see $twitterPost(...) for how to configure twitter account.

If user_p is supplied, it will return the messages posted by the account specified.

Parameters
user_p message filter on twitter user account, pass blank $(twitterGet('') to retrieve all messages.
Returns
  • tweet messages strung together.
Throws
Exception

public void twitterPost (String msg_p)

Since: API Level v2

sends a status update message to the twitter account pre-configured. To configure twitter, you must configure twitter by defining the following 4 properties in config.properties:

  • twitter.consumerKey - twitter application.
  • twitter.consumerSecrete - twitter application.
  • twitter.accessToken - twitter account to post updates to.
  • twitter.accessSecrete - twitter account to post updates to.

You need to register your application to obtain consumerKey and consumeSecrete at http://twitter.com/oauth_clients/new. To acquire accessToken and tokenSecrete, you must grant the application you've registered to the twitter account and generate the the accessToken and accessSecrete from twitter web site.

The message must be no more than 140 characters. Message longer than 140 characters will be truncated. Be aware duplicate message may be rejected by twitter.com. To ensure the message is posted, append a random number.

Parameters
msg_p - tweet message
Throws
Exception

public String waitForVarChanged (String varName_p, String timeoutMillis_p, String newValue_p)

Since: API Level v2

waits until the variable specified has changed its value. No timeout. Use this function to wait for signal from another model. This function is intended to be used as communication between model executions and not within the same model execution in FSM.

In concurrent modeling edition, since the transitions are executed concurrently, you this function can be used as communication between transitions (parallel execution of transitions).

Returns
  • new value
Throws
Exception

public String waitForVarChanged (String varName_p)

Since: API Level v2

waits until the variable specified has changed its value and return the new value. No timeout. Use this function to wait for signal from another model. This function is intended to be used as communication between model executions and not within the same model execution in FSM.

In concurrent modeling edition, since the transitions are executed concurrently, you this function can be used as communication between transitions (parallel execution of transitions).

Returns
  • new value set for the var.
Throws
Exception

public String waitForVarChanged (String varName_p, String timeoutMillis_p)

Since: API Level v2

waits until the variable specified has changed its value and return the new value. This function waits up to the timeout setting specified and returns "TimedOut" if timeout occurs. Use this function to wait for signal from another model. This function is intended to be used as communication between model executions and not within the same model execution in FSM.

In concurrent modeling edition, since the transitions are executed concurrently, you this function can be used as communication between transitions (parallel execution of transitions).

Parameters
timeoutMillis_p timeout in millis
Returns
  • "TimedOut" if timeout was triggered, or the actual value.
Throws
Exception

public String writeDataSet (String dataSetID_p, String outFileName_p, String delimiter_p, String fieldList_p)

Since: API Level v2

writes the specified columns in dataset to file using specified column delimiter. Example:

$writeDataSet('ds1','out.txt', '[tab]', 'f1;f2')

The above example causes the content of the dataset 'ds1' to be written to file at 'c:/serverInstall/model/myModel/dataset/out.txt' using tab as the column delimiter. Only columns labeld "f1" and "f2" are written to the file.

Parameters
dataSetID_p name of the dataset
outFileName_p name of the output file in DataSet folder
delimiter_p delimiter
fieldList_p list of field names separated by semi-colon ";"
Returns
  • full path of the output file
Throws
Exception
Exception

public String writeDataSet (String dataSetID_p, String outFileName_p, String delimiter_p)

Since: API Level v2

writes all columns in the dataset out to a file using the column delimiter specified.

Example:

$writeDataSet('ds1','out.txt', '[tab]')
The above expression returns 'c:/serverInstall/model/myModel/dataset/out.txt'.

The above example causes the content of the dataset 'ds1' to be written to file at 'c:/serverInstall/model/myModel/dataset/out.txt' using tab as the column delimiter.

Parameters
dataSetID_p name of the dataset
outFileName_p name of the output file in DataSet folder
delimiter_p delimiter
Returns
  • full path of the output file
Throws
Exception
Exception

public boolean xor (String... exprList_p)

Since: API Level v2

performs XOR on the expression list passed. blank exprs are ignored (equivalent to true).

Parameters
exprList_p list of expressions, each expression in a separate parameter.
Returns
  • true/false
Throws
Exception
See Also
  • and(String ...)