Comment on page
WEM Test Script
This part is a limited first edition to describe some of the WEM Test Script DSL features as part of the WEM Regression Test Framework.
In future, we plan to provide a Portal in which you can manage your own testsuites and scripts, request test-executions and review test-results. This WEM Test Script will be an important part.
Statements that can be used in the WEM Test Scripts to perform specific actions.
Use := to assign an expression/value or a web element (an element on your page in the Runtime to work with) to a local variable.
$<variable-name> := <expr>
$<variable-name> := <webEl>
Make a screenshot of the current page. Screenshots will be compared to check differences between the test environment and the reference environment.
If no name is given, a default name will be used like: "#-screenshot".
The resulting screenshots can be accessed in the Artifacts collection of the Job Execution Result.
Navigate to a specified page (perform an HTTP-GET request).
navigate to <page>
<page>value will be added to the end of the given base URL (test/reference host + relative path). If
<page>starts with https:// or http://, the base URL will be ignored and
<page>will be considered an absolute path (which may be an external URL).
Every script should start with a Navigate to statement.
Perform a Click-action on specified (web) element.
click on <webEl>
Hover over a web element, to test tooltips.
hover over <webEl>
Select value or text from specified web element, like a dropdown.
select <value> from <webEl>
select text <value> from <webEl>
select value <value> from <webEl>
Optional keyword text or value, determines which attribute is used for <value>, default is text.
Put a value into specified web element, most useful to perform adding values to Input Fields.
enter <value> into <webEl>
Capture text or html of specified web element.
capture <webEl> <name>
capture text <webEl>
capture html <webEl>
Optional keyword text or html, determines whether outer-html or text is captured, default is text.
Wait for a duration specified in milliseconds. This may be required if certain actions (loading a page, retrieving data) take a longer time. With Test Automation it is sometimes necessary to put in manual wait statements to make sure that the test can perform realistically and this means to have to wait until some longer running process is finished before the next step should be executed. Often this is a matter of trying a few times until the optimal waiting time is found...
Tries to download specified link.
Use Wait at the end of the script if it's a big download.
Download does not work in Edge browser.
<link>parameter should be the Text attribute of the link (the visible text that is clickable).
The resulting file can be accessed in the Artifacts collection of the Job Execution Result.
Resize browser viewport (to test responsive elements) to indicated width and height. When no arguments are present it will revert back to full screen. If height is not present, the width-value will be used for height as well.
Resize <width> <height>
Continues executing statement block while
endspecifies end of statement block. Optional keyword
break, if this is reached, the loop is ended and flow continues after the
<condition>is true, executes statement block.
endspecifies end of statement block. Optional keyword
elseif, if previous conditions are false, execute the statements in the
elseifblock, if its specified condition is true. Optional keyword
else, if previous conditions are false, execute the statements in the
Every new statement should be on a new line.
Get the web element in another web element.
click on <webEl> in <webEl>
Check if one or the other is true.
if <condition> or <condition>
Check if both are true.
while <condition> and <condition>
if not <expr>
Compare values with each other. Equal (
=) or Not-Equal (
if <expr> = <expr>
Check if values are greater or less than (or equals).
while <expr> >= <expr>
$var := 1 + 2
$var := 1 * 2 - 3
$var := "Hello " + "world"
$var := "I am " + 42 + "years old"
$var := -$var
If + is used with a string, it concatenates all values into a string.
WebElements are html elements that can be interacted with using the above named statements.
- DataGrid (class=table)
To click on a datagrid or repeater "page", use the Pagination element: click on pagination[text=42]
Using selectors, the correct WebElement can be specified. If no selectors are present the first displayed element will be used.
Selectors available are: text, title, class, label, index and all html attributes. Index is a special selector, starting from 1 it chooses the element on the given index All other selectors after index will be ignored.
A special WebElement is Element. It has it's own special selectors, all other selectors won't work. These selectors are: id, xpath and css.
To avoid a "stale" WebElement exception (the specified element is no longer part of the current HTML Document in the Browser Session) use * in front of the WebElement to create a lazy expression, this will execute the expression only when needed. Only works on WebElements.
$var := button
$var := button
$var := button[class="succes", index=3, text="Ok"] #text="Ok" will not be reached
$var := *button[attr=<expr>, ...] #lazy webelement expression
- Boolean (true or false)
Exists(<webEl>)Checks if <webEl> hasn't gotten stale and still exists in the current HTML Document. Returns true or false.
Functions always have a return value
A lazy assignment of a button element to a variable using index as a selector. Using the function Exists() to check if the current button is still valid, and increasing the index selector by 1 to loop through all button elements on the page. Making a screenshot of all overlays and closing them using click on button[text="close"].
navigate to "/data/legacy-lists"
$i := 1
$button := *button[index=$i]
click on $button
screenshot "test_" + $i
click on button[text="close"]
$i := $i + 1
Using click on datagrid[title="ID"] to sort specified columns of a Datagrid.
navigate to "/data/advanceddatatests"
click on button[text="Test Filters"]
click on button[text="Test Filter 4: FilteredPaging"]
click on datagrid[title="ID"]
screenshot "Sort ID"
click on datagrid[title="Count Orgs"]
screenshot "Sort Orgs"
click on pagination[text=11] in panel
screenshot "Page 11"
click on pagination[text="next"]
screenshot "Page Next"
navigate to "/flowcharts/export-to-excel"
Entering "hello world" into a form-item. Afterwards collapsing the panel.
navigate to "/ui/input-components"
click on button[text="Texts"]
enter "hello world" into formitem[label="Text 03"] in panel
click on panel
Enter values into form-input
Change language to Italian using the dropdown and capturing the html of a web element.
navigate to "/ui/built-in-components"
click on button[text="Labels"]
$table := *element[css="body>form>main>div:nth-child(5)"]
select "Italian (Italy)" from input[name="wmtlang"]
capture html $table