JScript Language Reference¶
Important
Starting from Rapise 8.0, the default JavaScript engine is NodeJS v14.15.3 runtime. Starting from Rapise 8.1, the default JavaScript engine is NodeJS v18.18.0 runtime.
In versions prior to 6.7, Rapise used Microsoft JScript with WScript as the only available JavaScript engine. This document provides a language reference for that older version.
If you have existing tests or testing frameworks that are not compatible with NodeJS, you have the option to switch back to using WScript.
You can set the desired engine in two locations:
-
In the Test Settings (choose from Default, Node, WScript). The Default option uses the engine defined in the Global Options.
-
In the Global Options (choose from Default, Node, WScript). The Default option means Node.
NodeJS Support Features and Limitations¶
Features¶
- NodeJS v18 contains most of the latest features of JavaScript, including EcmaScript2015 (ES6) and beyond. A more detailed list of features is available here.
- The most complete and up-to-date language reference can be found at https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference.
- You can use most available npm packages in your test scripts. You can include
node_modules
folders in the root of your testing framework (i.e.,%WORKDIR%\node_modules
).
Limitations¶
-
The NodeJS engine now runs in 32-bit mode. This is required to maintain compatibility with
ActiveXObject
support, which is an essential part of WScript but must be emulated in NodeJS. -
Rapise has its own copy of node.exe installed. Therefore, if you have npm modules installed globally and need to use them in your tests, you must install them locally within the framework.
Npm Console¶
This section assumes your testing framework is running with NodeJS enabled (which is the case unless you are using an older testing framework).
You can integrate external NPM modules and packages into your test scripts. However, when using an external package, be sure to install it using Rapise's built-in package manager. Installing via a global package manager (if available) makes the packages visible to global scripts but not within Rapise tests. Instead, use the internal npm
console provided by Rapise, which is tied to the NodeJS instance running your tests.
To access the internal npm
console, go to the Tools > Npm Console
menu.
After opening the console, you can install any package as usual.
You have the option to save the installed packages alongside your tests or simply save the package.json
or package-lock.json
files and restore the dependencies when needed.
function _NpmInit()
{
// Restore packages if necessary.
// This assumes that the framework root folder contains a package.json file.
if (!File.FolderExists(g_workDir + '\\node_modules'))
{
const npmCmd = g_helper.ResolvePath("InstrumentJS/npm.cmd");
Global.DoCmd('"' + npmCmd + '"' + " install --prefix \"" + g_workDir + "\"", g_workDir, true, false);
}
}
For example, you can call _NpmInit
from the SeSOnTestInit() function.
Reference¶
The language reference covers EcmaScript v2, which is supported by the default JScript Engine. It is missing the majority of the latest features, properties, and methods. For example, there is no Array.join
or String.trim
.
- GetObject Function
- ScriptEngine Function
- ScriptEngineBuildVersion Function
- ScriptEngineMajorVersion Function
- ScriptEngineMinorVersion Function
Methods A-C¶
- abs Method
- acos Method
- anchor Method
- apply Method
- asin Method
- atan Method
- atan2 Method
- atEnd Method
- big Method
- blink Method
- bold Method
- call Method
- ceil Method
- charAt Method
- charCodeAt Method
- compile Method
- concat Method (Array)
- concat Method (String)
- cos Method
Methods D-F¶
- decodeURI Method
- decodeURIComponent Method
- dimensions Method
- encodeURI Method
- encodeURIComponent Method
- escape Method
- eval Method
- exec Method
- exp Method
- fixed Method
- floor Method
- fontcolor Method
- fontsize Method
- fromCharCode Method
Methods G¶
- getDate Method
- getDay Method
- getFullYear Method
- getHours Method
- getItem Method
- getMilliseconds Method
- getMinutes Method
- getMonth Method
- getSeconds Method
- getTime Method
- getTimezoneOffset Method
- getUTCDate Method
- getUTCDay Method
- getUTCFullYear Method
- getUTCHours Method
- getUTCMilliseconds Method
- getUTCMinutes Method
- getUTCMonth Method
- getUTCSeconds Method
- getVarDate Method
- getYear Method
Methods I-M¶
- indexOf Method
- isFinite Method
- isNaN Method
- italics Method
- item Method
- join Method
- lastIndexOf Method
- lbound Method
- link Method
- localeCompare Method
- log Method
- match Method
- max Method
- min Method
- moveFirst Method
- moveNext Method
Methods P-R¶
- parse Method
- parseFloat Method
- parseInt Method
- pop Method
- pow Method
- push Method
- random Method
- replace Method
- reverse Method
- round Method
Methods S¶
- search Method
- setDate Method
- setFullYear Method
- setHours Method
- setMilliseconds Method
- setMinutes Method
- setMonth Method
- setSeconds Method
- setTime Method
- setUTCDate Method
- setUTCFullYear Method
- setUTCHours Method
- setUTCMilliseconds Method
- setUTCMinutes Method
- setUTCMonth Method
- setUTCSeconds Method
- setYear Method
- shift Method
- sin Method
- slice Method (Array)
- slice Method (String)
- small Method
- sort Method
- splice Method
- split Method
- sqrt Method
- strike Method
- sub Method
- substr Method
- substring Method
- sup Method
Methods T-V¶
- tan Method
- test Method
- toArray Method
- toDateString Method
- toExponential Method
- toFixed Method
- toGMTString Method
- toLocaleDateString Method
- toLocaleLowerCase Method
- toLocaleString Method
- toLocaleTimeString Method
- toLocaleUpperCase Method
- toLowerCase Method
- toPrecision Method
- toString Method
- toTimeString Method
- toUpperCase Method
- toUTCString Method
- ubound Method
- unescape Method
- unshift Method
- UTC Method
- valueOf Method
Objects¶
- ActiveXObject Object
- Array Object
- arguments Object
- Boolean Object
- Date Object
- Enumerator Object
- Error Object
- Function Object
- Global Object
- Math Object
- Number Object
- Object Object
- RegExp Object
- Regular Expression Object
- String Object
- VBArray Object
Operators¶
- Addition Assignment Operator (+=)
- Addition Operator (+)
- Assignment Operator (=)
- Bitwise AND Assignment Operator (&=)
- Bitwise AND Operator (&)
- Bitwise Left Shift Operator (<<)
- Bitwise NOT Operator (~)
- Bitwise OR Assignment Operator (|=)
- Bitwise OR Operator (|)
- Bitwise Right Shift Operator (>>)
- Bitwise XOR Assignment Operator (^=)
- Bitwise XOR Operator (^)
- Comma Operator (,)
- Comparison Operators
- Compound Assignment Operators
- Conditional (Ternary) Operator (?:)
- delete Operator
- Division Assignment Operator (/=)
- Division Operator (/)
- in Operator
- Increment (++) and Decrement (--) Operators
- instanceof Operator
- Left Shift Assignment Operator (<<=)
- Logical AND Operator (&&)
- Logical NOT Operator (!)
- Logical OR Operator (||)
- Modulus Assignment Operator (%=)
- Modulus Operator (%)
- Multiplication Assignment Operator (*=)
- Multiplication Operator (*)
- new Operator
- Right Shift Assignment Operator (>>=)
- Subtraction Assignment Operator (-=)
- Subtraction Operator (-)
- typeof Operator
- Unsigned Right Shift Operator (>>>)
- Unsigned Right Shift Assignment Operator (>>>=)
- void Operator
Properties¶
- 0...n Properties
- $1...$9 Properties
- arguments Property
- callee Property
- caller Property
- constructor Property
- description Property
- E Property
- global Property
- hasOwnProperty Method
- ignoreCase Property
- index Property
- Infinity Property
- input Property ($_)
- isPrototypeOf Method
- lastIndex Property
- leftContext Property ($`)
- length Property (arguments)
- length Property (Array)
- lastMatch Property ($&)
- lastParen Property ($+)
- length Property (Function)
- length Property (String)
- LN10 Property
- LN2 Property
- LOG10E Property
- LOG2E Property
- MAX_VALUE Property
- message Property
- MIN_VALUE Property
- multiline Property
- name Property
- NaN Property
- NaN Property (Global)
- NEGATIVE_INFINITY Property
- number Property
- PI Property
- POSITIVE_INFINITY Property
- propertyIsEnumerable Property
- prototype Property
- rightContext Property ($')
- source Property
- SQRT1_2 Property
- SQRT2 Property
- undefined Property
Statements¶
- @cc_on Statement
- @if Statement
- @set Statement
- break Statement
- Comment Statements
- continue Statement
- do...while Statement
- for Statement
- for...in Statement
- function Statement
- if...else Statement
- Labeled Statement
- return Statement
- switch Statement
- this Statement
- throw Statement
- try...catch...finally Statement
- var Statement
- while Statement
- with Statement
JScript Fundamentals¶
- What Is JScript?
- Writing JScript Code
- JScript Variables
- JScript Data Types
- JScript Operators
- Operator Precedence
- Controlling Program Flow
- JScript Functions
- JScript Objects
- Creating Your Own Objects
- Intrinsic Objects
- JScript Reserved Words
Advanced JScript¶
- Advanced Object Creation
- Recursion
- Variable Scope
- Copying, Passing, and Comparing Data
- Using Arrays
- Special Characters
- Troubleshooting Your Scripts
- Conditional Compilation
- Conditional Compilation Variables
Introduction to Regular Expressions¶
- Regular Expressions
- Early Beginnings
- Uses for Regular Expressions
- Regular Expression Syntax
- Build a Regular Expression
- Order of Precedence
- Ordinary Characters
- Special Characters
- Non-Printable Characters
- Character Matching
- Quantifiers
- Anchors
- Alternation and Grouping
- Backreferences