testRigor advanced topics

testRigor provides you full interface to JavaScript with ability to access the full power of testRigor via interface.
JavaScript Support
testRigor allows you to use JavaScript and refer to testRigor’s commands like so:
store value "hello" as "var1"
execute JavaScript text starting from next line and ending with [END]
  if (testRigor.hasStoredValue("var1")) {
    testRigor.execute('enter stored value "var1" into "Message"');
  }
  testRigor.execute('click "Update"');
  testRigor.execute('check that page contains text from stored value "var1"');
[END]
JavaScript supported is fully ECMAScript 5.1 compatible.
testRigor interface
testRigor interface is as following:
interface TestRigor {
  /**
   * True if variable had been assigned a value.
   */
  boolean hasStoredValue(String storedValueName);
  /**
   * Gets the value of the variable.
   */
  String getStoredValue(String storedValueName);
  /**
   * Sets the value of variable.
   */
  String putStoredValue(String storedValueName, String value);
  /**
   * Extracts the full variable-to-value map.
   */
  Map<String, String> getReadOnlyStoredValuesMap();
  /**
   * Gets tree of elements for the current screen.
   */
  UiElement getNodeTree();
  /**
   * Execute the commands. Can be multiple commands new-line separated.
   */
  boolean execute(String commands);
}
Screen/Page structure
The interface UiElement is as following:
interface UiElement {
  String getElementName();
  String getHtmlNodeName();
  double getY();
  double getX();
  double getHeight();
  double getWidth();
  UiElement getParent();
  String getText();
  String getPath();
  String getShortPath();
  String getFullPath();
  String getName();
  String getLabel();
  String getHint();
  String getTitle();
  String getClassName();
  String getResourceId();
  String getOcrText();
  String getPlaceholder();
  String getAlternative();
  String getType();
  String getValue();
  String getAriaLabel();
  String getRole();
  boolean isVisible();
  boolean isEnabled();
  boolean isClickable();
  boolean isChecked();
  boolean hasProperty(String propertyName);
  String getProperty(String propertyName);
}
Above, most of the properties are directly from XML/HTML, except calculated ones:
  1. x
  2. y
  3. height
  4. width
  5. visible
  6. ocrText – only available if OCR is enabled
  7. shortPath – short version of XPath leveraging ids where possible
  8. fullPath – direct full XPath from the root
  9. path – one of the above based on the settings
Note, that id is stored in resourceId attribute
Element interactions
Referencing elements is parsed using ML-based NLP, but can be thought as the following stricture in simplified Pseudo-EBNF:
command [index] [typeOfElement] ["containing"] ["saved value" | "parameterized string"] [elementReference] ["in the context of", elementReference]
Where:
elementReference = \"elementName\", {"or", elementReference} [insideTableReference]
Where:
insideTableReference = "at" ["row", elementReference] ["column", elementReference]
For example:
click on the first button "delete" or "remove" in the context of the first table "visible" at the row containing saved value "generatedId" and column "actions"
Or you can refer elements directly through:
click XPath "/html/body/div[3]"
Or:
click CSS Selector "a[target=_blank]"