TextScriptRunner Scripting Mini-Language

This document describes the scripting language interpreted by the TextScriptRunner: General Notes:

Commands fall into a few broad areas:
  1. The browse, back, and refresh Command to simulate web page navigation
  2. The set Command (For Setting Values)
    This should be your universal command for changing the value of any standard form element.
  3. The select Command (For Changing Context)
    This should be your universal command for changing the focus of the test, e.g. a Form or Window
  4. The click Command (For Actions)
    This should be your command for clicking any element that causes an action, like a button, a link, or an image map area.
  5. The validate, getValue or VerifyContains Command (for Verification)
  6. The include, fail, and delay Command to Include a script file, run a command that you expect to Fail or Delay script execution
  7. The setWebOption Command to change Web-related options
  8. The setOption Command to set TextScriptRunner options
  9. The GetVariable and SetVariable to allow for scripting variables
  10. The Connect and Query Commands to connect to a database and run queries
  11. The Login and RunShellCommand Commands to login to a (*nix) host and execute shell commands
Verb Args Example Description
Browse URL Browse http://TextScriptRunner.com Open a web client connection to the specified URL and return the contents. The current page is set to the result of that connection
Back Back Emulates clicking the 'Back' arrow/button on your Browser to return to the previous page
WaitForText text WaitForText "some bit of text" Since a lot of JS/Ajax (e.g. click, select, etc) fires off an event and returns, this allows you to wait for some text to show up (that you expect)
WaitForElement ElementID or ElementName WaitForElement verifyRegistration Since a lot of JS/Ajax (e.g. click, select, etc) fires off an event and returns, this allows you to wait for an element to show up (that you expect)
Refresh Refresh Emulates clicking the 'refresh'/button on your Browser to reload the current page
Set FieldName Value Set email joe@example.com Set/Enter the Value into the field with name FieldName on the current page/form
DeprecatedSelectRadioButton FieldName Value SelectRadioButton gender Male Selects the option Value from the options for RadioButoon group with name FieldName on the current page/form
DeprecatedUse Click instead
Select TypeName Value Select Form Gender Selects the TypeName (Window, Form) with name FieldName on the current page/form
SubmitForm FormName Value SubmitForm Search This is somewhat of a hack those those web developers who are too lazy to add a submit button to their form. It simulates the user hitting the enter button on a field in a form.
Click NameOrID Click login Simulates the user clicking on the element with name or ID NameOrID on the current page/form to cause an action
Validate FieldName ExpectedValue Validate OrderID 63 Compares the value of the field labeled FieldName on the current page/form to the ExpectedValue
Note: the FieldName IS case-sensitive
Note: for a CheckBox or a RadioButton, Validate the FieldName is True or False
GetValue FieldName GetValue myCalc Locates the field labeled with name MyCalc and returns the value.
Note: FieldName is case-sensitive
VerifyContains Value VerifyContains 'Common Problems:' Verifies that the current form or page contains Value
Include FileName Include UserLogin.txt Executes the contents of Filename as if it were included at this point in the script.
Fail Verb Args Fail ClickLink viewOrder?id=42 Executes the specified Verb with Arguments as specified above, but expects the result to FAIL. This is used to test permission errors, invalid previous results/test cases, invalid selection options, out of range field entries, etc
Delay Amount (seconds) Delay 5 Delays the execution of the next step in the script by Amount seconds.
Comment or # CommentText Comment Next step includes the login script A no-op that allows you to put documentation/comments in the script
SetOption SettingName Value SetOption DisplayLevel Verbose Sets the option SettingName to Value
Here are the current supported SettingNames:
  • DisplayLevel MINIMAL, NORMAL(the default), VERBOSE
GetOption SettingName Get DisplayLevel Gets the value of the SettingName
SetWebOption SettingName Value SetWebOption JavaScriptEnabled true Sets the option SettingName to Value
Here are the settings and current defaults:
  • CookiesEnabled true, false (the default)
  • JavaScriptEnabled true(the default), false
  • CssEnabled true, false(the default)
  • GeolocationEnabled true, false(the default)
  • DoNotTrackEnabled true(the default), false
  • ThrowExceptionOnScriptError true, false(the default)
  • ThrowExceptionOnFailingStatusCode true, false(the default)
  • waitForBackgroundJavaScript 1000 (1 second, the default)
  • Timeout 20000 (20 seconds, the default)
GetWebOption SettingName GetWebOption JavaScriptEnabled Gets the value of the web-related setting for option SettingName
GetVariable ${VariableName} GetVariable ${BaseURL} Gets the value of the variable named VariableName
SetVariable VariableName Value SetVariable BaseURL http://textscriptrunner.com/ Sets the variable VariableName to Value for later use
Help Help Returns the contents of this page - more details to be added later for each command.
Connect Connect jdbc:mysql://your_host:3306/your_database user42 password42 Open a SQL client connection to the specified Database URL using the specified username and password.
Query SQL Query "select * from users" Returns the result of executing the SQL against the currently connected data source
Login Connect textscriptrunner.com user42 password42 Open connection to the specified IP or hostname using the specified username and password.
RunShellCommand command RunShellCommand "ls -l" Returns the result of executing the command on the currently connect host
© 2022-2025 TextScriptRunner