Summary and scope

These notes on Selenese syntax are on top of Selenium documentation. See EnhancedSelenese on how SeLite improves it.

Auto-generated Selenese commands

Selenese commands are defined in these primary forms: xyz, getXyz, isXyz or isXyzPresent. Selenium auto-generates their variations (listed below).

Selenium IDE shows the original reference for both the primary and auto-generated commands. However, the online reference contains only the primary commands. So if you’d like to locate them online (or in the source), use the following. (See also loadSeleniumCommands() in Selenium IDE’s treeView.js.)

Primary command
(as listed both online and in Reference tab; same as Javascript implementation function, unless mentioned otherwise)
Auto-generated commands
(listed in Reference tab only, but not online)
xyz
(implemented by function doXyz)
xyzAndWait
   
assertXyz verifyXyz
   
getXyz
isXyz (other than isXyzPresent)
(both are rarely useful on their own
- use generated commands instead)
assertXyz
assertNotXyz
  verifyXyz
verifyNotXyz
  storeXyz
  waitForXyz
waitForNotXyz
   
isXyzPresent
(rarely useful on its own
- use generated commands instead)
assertXyzPresent
assertXyzNotPresent
  verifyXyzPresent
verifyXyzNotPresent
  storeXyzPresent
  waitForXyzPresent
waitForXyzNotPresent

Selenese parameters (target and value)

Selenese commands accept up to two parameters: target and value.

XPath

Full XPath locators start with xpath= or with //. Usually an XPath expression starts with //, with which you don’t need to use xpath=. However, some SeLite commands (like clickRandom and selectRandom) only accept XPath as the locator, but they require it not to contain any leading xpath= prefix (whether the XPath starts with // or not).

See resources on XPath:

UI-Element mappings

UI Mapping (or ‘UI-Element mapping’) defines a mapping between meaningful names of elements on webpages, and the elements themselves. Element locators are in forms

Find a basic example at Selenium Documentation > Test Design Considerations > UI Mapping (which is written in Java, but SeLite frameworks define UI Mappings in Javascript.) See also a more detailed example (or at chrome:// URL chrome://selenium-ide/content/selenium-core/scripts/ui-map-sample.js). Read its detailed reference. If you’ve installed Selenium IDE, access the same reference offline through Selenium IDE menu > Help > UI-Element Documentation (or at chrome://selenium-ide/content/selenium-core/scripts/ui-doc.html).

Variables

Stored variables

Some Selenese commands store variables, to be used by later steps. SelBlocks Global manages scope of such variables. When inside a SelBlocks Global function, you can only use stored variables set in that function (or passed as parameters to it). The local scope also means: if you set a stored variable within a Selenese function and the same stored variable exists in the caller scope (that invoked the current function), the variable in the caller scope won’t be affected.

Parameters of Selenese commands can access stored variables as ${name-of-the-variable}. Those get replaced by the value of the variable. However, if a command processes the parameter as a Javascript expression (e.g. storeEval, getEval or when using EnhancedSelenese), and if the variable contains an array/object or a non-numeric string (possibly with an apostrophe or quotation mark), then replacement of ${name-of-the-variable} won’t work robustly. For those cases use $name-of-the-variable (or storedVars.name-of-the-variable or storedVars['name-of-the-variable']). See also EnhancedSelenese.

Javascript variables

Sometimes you want a global variable that spreads across Selenese functions (which stored variables can’t). Use native Javascript variables for it. Set them using command getEval with target being: variable1=valueOrExpression, variable2=valueOrExpression....

Don’t use storeEval for that - it sets a stored variable, which is local to current Selenese function.

ECMAScript 6

Firefox supports many ECMAScript 6 features. Template Literals are useful especially with Javascript variables (rather than with stored variables).

However, that is in conflict with standard Selenese use of `${...}` to access stored variables. See Selenium IDE > Store Commands and Selenium Variables. See ThirdPartyIssues > Support ECMAScript 6 Template Literals.

Limitations of getEval and its derivatives

Command getEval (and derived commands like storeEval - as per Auto-generated Selenese commands above) etc. don’t like new line string literals "\n" or '\n' (or any string literals that contain them). Then they generate a confusing error unterminated string literal. Use String.fromCharCode(10) or '\\u000A' (as per a suggestion) instead.

These commands use Javascript eval(). That doesn’t return values of some expressions as expected, e.g. {field: "value"}. If you want that, enclose them in parenthesis. For example: getEval | ({ field: "value" }).