-
Notifications
You must be signed in to change notification settings - Fork 2
Web Commands
Testlum provides a wide range of commands specifically designed for web application testing.
Using these commands, you can interact with web elements, perform browser actions, validate page states, handle user inputs, and much more.
This section will guide you through the available web commands, their usage patterns, and best practices to build stable and efficient web tests across multiple browsers and devices.
π Categories
Testlum web commands are grouped into the following functional areas:
πΉ Interaction commands
click
doubleClick
input
dropDown
hovers
hotKey
clear
dragAndDrop
navigate
scroll
scrollTo
tab
switchToFrame
assert
image
javascript
wait
repeat
include
β Each category contains commands tailored to specific test actions, helping you quickly find and apply the right tool during scenario creation.
The
<web>
tag serves as the main interpreter for interacting with the user interface. It encompasses a set of commands, including navigation, waiting, and actions like clicking. The<web>
tag organizes these commands into a single structure, allowing you to control browser behavior.<web comment="Start web scripts"> <navigate command="to" comment="Go to base page" path="/shop/"/> <wait comment="Wait for visualizing a click" time="2" unit="seconds"/> <click comment="Click on the 'Shopizer' website link which opens in a new window" locator="shopizer.webSiteShopizer"/> </web>β Tip:
The<web>
tag allows you to bundle multiple actions into a single sequence for easy navigation and interaction with a webpage.
Interaction Commands
This section describes commands that simulate user interactions, such as clicking, typing, hovering, and dragging elements.
click
The click
command is used to simulate a user click action on a specific element on the page.
Parameter | Type | Required | Default | Description |
---|---|---|---|---|
comment |
String | β | - | Description of the purpose of the click action |
locator |
String | β | - | Locator ID or strategy to find the element to click |
method |
selenium javascript
|
β | selenium |
The click method to use (selenium or javascript ) |
highlight |
Boolean | β | false |
Whether to visually highlight the clicked element (grey background, yellow border) |
condition |
Boolean | β | - | Condition to decide if this step should be executed |
threshold |
Integer (ms) | β | - | Maximum allowed execution time; step fails if exceeded |
locatorStrategy |
String | β | locatorId |
Custom locator strategy if needed (more info in Locators Guide) |
<click comment="Click on 'Sign In' button" locator="login.signIn"/>
β Tip:
- Use
highlight="true"
during debugging sessions to see where clicks are happening!- Use
method="javascript"
if the Selenium click doesn't work (e.g., for hidden or tricky elements).
doubleClick
The doubleClick
command simulates a double-click action on a specified element.
Parameter | Type | Required | Default | Description |
---|---|---|---|---|
comment |
String | β | - | Description of the purpose of the double-click action |
locator |
String | β | - | Locator ID or strategy to find the element to double-click |
highlight |
Boolean | β | false |
Whether to visually highlight the double-clicked element (grey background, yellow border) |
condition |
Boolean | β | - | Condition to decide if this step should be executed |
threshold |
Integer (ms) | β | - | Maximum allowed execution time; step fails if exceeded |
locatorStrategy |
String | β | locatorId |
Custom locator strategy if needed (more info in Locators Guide) |
<doubleClick comment="Double click on button" locator="login.button"/>
β Tip:
- Use
highlight="true"
during debug runs to see which element is being double-clicked.- If the element is tricky to access (e.g., hidden under layers), consider using a custom
locatorStrategy
.
input
The input
command is used to enter text or file data into a specific field based on a locator.
Parameter | Type | Required | Default | Description |
---|---|---|---|---|
comment |
String | β | - | Description of the input action |
locator |
String | β | - | Locator ID or strategy for the field to input into |
value |
String | β | - | Value to be entered into the field (text or file reference) |
highlight |
Boolean | β | false |
Highlight the field during execution (useful for debugging) |
condition |
Boolean | β | - | Condition to determine if this step should be executed |
locatorStrategy |
String | β | locatorId |
Custom locator strategy if needed (more info in Locators Guide) |
threshold |
Integer (ms) | β | - | Maximum allowed execution time; step fails if exceeded |
<input comment="Input first name" locator="ownerRegistration.firstName" value="Mario"/>
locator
defines the UI element to interact with.value
is the text you want to input.
You can also upload an image or file using the input
command.
The file must be located in the same folder as your test scenario.
<input comment="Add profile photo" locator="userPhoto.addProfilePhotoButton" value="file:Firmino.jpg"/>
- Prefix the
value
withfile:
to indicate a file upload.Firmino.jpg
should be placed in the same scenario folder.
β Tip:
Usehighlight="true"
when debugging forms or uploads to visually confirm the fields being targeted.
dropDown
The dropDown
command is used to select or deselect options inside a dropdown menu.
Parameter | Type | Required | Default | Description |
---|---|---|---|---|
comment |
String | β | - | Description of the dropdown interaction |
locator |
String | β | - | Locator ID or strategy for the dropdown element |
type (inside oneValue /allValues ) |
String | β | - | Action to perform: select or deselect
|
by (only for oneValue ) |
String | β
(if oneValue ) |
- | How to select an option: by Text , Value , or Index
|
value (only for oneValue ) |
String | β
(if oneValue ) |
- | Value for selection according to the by strategy |
condition |
Boolean | β | - | Condition to decide if this step should be executed |
threshold |
Integer (ms) | β | - | Maximum allowed execution time; step fails if exceeded |
locatorStrategy |
String | β | locatorId |
Custom locator strategy if needed (more info in Locators Guide) |
<dropDown comment="Deselect all countries" locator="registration.country"> <allValues type="deselect"/> </dropDown> <dropDown comment="Select first value from dropDown" locator="registration.country"> <oneValue type="select" by="index" value="1"/> </dropDown>
β Tips:
- Use
oneValue
if you need to select/deselect a specific option based on its text, value, or index.- Use
allValues
only when you want to deselect everything from a multi-select dropdown.
hover
The hover
command moves the mouse cursor over a specific UI element, triggering hover-based UI behaviors like dropdown menus or tooltips.
Parameter | Type | Required | Default | Description |
---|---|---|---|---|
comment |
String | β | - | Description of the hover action |
locator |
String | β | - | Locator ID or strategy for the element to hover over |
condition |
Boolean Expression | β | - | Condition to decide if this step should be executed |
threshold |
Integer (ms) | β | - | Maximum allowed execution time; step fails if exceeded |
locatorStrategy |
String | β | locatorId |
Custom locator strategy if needed (more info in Locators Guide) |
<hover comment="Open drop down 'Novels' tab" locator="locator.novels"/>
β Tip:
Hovering can be used to reveal hidden menus or additional options without clicking.
hotkey
The hotKey
command simulates pressing individual keys or key combinations on the keyboard, such as backSpace
, copy
, cut
, enter
, escape
, highlight
, paste
, space
, tab
.
Parameter | Type | Required | Default | Description |
---|---|---|---|---|
comment |
String | β | - | Description of the hotkey action |
locator |
String | β | - | Locator ID or strategy for the element associated with the hotkey action |
times |
Integer | β | 1 |
Number of times to repeat the hotkey action |
<hotKey comment="Paste the password"> <paste comment="Paste the password" locator="hotKey.password"/> </hotKey>
- This example uses
locator
to specify the field where the hotkey (paste) will be executed.
<hotKey comment="Click enter"> <enter comment="Click enter" times="2"/> </hotKey>
- This example uses
times
to specify how many times theEnter
key will be pressed.
β Tip:
For non-locator actions liketab
,space
, orbackspace
, just use the key name and set thetimes
parameter to control how many times the key is pressed.
clear
The clear
command is used to clear any text or value entered in a specified input field.
Parameter | Type | Required | Default | Description |
---|---|---|---|---|
comment |
String | β | - | Description of the clearing action |
locator |
String | β | - | Locator ID or strategy for the input field to clear |
highlight |
Boolean | β | false |
Whether to highlight the cleared field (grey background, yellow border) |
condition |
Boolean | β | - | Condition to decide if this step should be executed |
threshold |
Integer (ms) | β | - | Maximum allowed execution time; step fails if exceeded |
locatorStrategy |
String | β | locatorId |
Custom locator strategy if needed (more info in Locators Guide) |
<clear comment="Clear password" locator="demoNative.clear" highlight="true"/>
β Tip:
Usehighlight="true"
for better debugging during development to visually confirm that the field was cleared.
dragAndDrop
The dragAndDrop
command allows you to drag an element from one location and drop it onto another.
Parameter | Type | Required | Default | Description |
---|---|---|---|---|
comment |
String | β | - | Description of the drag-and-drop action |
toLocator |
String | β | - | Locator ID of the target location where the element is dropped |
fromLocator |
String | β | - | Locator ID of the element to drag |
fileName |
String | β | - | File name to upload during drag-and-drop (must be in the same folder as the test scenario) |
condition |
Boolean | β | - | Condition to decide if this step should be executed |
threshold |
Integer (ms) | β | - | Maximum allowed execution time; step fails if exceeded |
locatorStrategy |
String | β | locatorId |
Custom locator strategy if needed (more info in Locators Guide) |
<dragAndDrop comment="Drag and drop action" toLocator="nativeDrag.dragFirst"> <fromLocator>nativeDrag.dropSecond</fromLocator> </dragAndDrop>
<dragAndDrop comment="Add image with dragAndDrop example" toLocator="dragAndDrop.image"> <fileName>/home/user/image.jpg</fileName> </dragAndDrop>
- Use
fileName
to upload a file during the drag-and-drop action. The file must be located in the same folder as the test scenario.
Navigation and Scrolling Commands
This section covers commands that help you navigate between pages, scroll through content, and interact with frames.
navigate
The navigate
command is used to perform different navigation actions, such as moving forward, backward, or reloading the page.
Parameter | Type | Required | Default | Description |
---|---|---|---|---|
comment |
String | β | - | Description of the navigation action |
command |
String | β | - | Navigation action: back , reload , or to
|
path |
String | β | - | Path to navigate to when command="to"
|
condition |
Boolean Expression | β | - | Condition to decide if this step should be executed |
threshold |
Integer (ms) | β | - | Maximum allowed execution time; step fails if exceeded |
<navigate comment="Go to register account page" command="to" path="/registerAccount"/>
- Use
command="to"
with thepath
parameter to navigate to a specific URL or page path.
β Tip:
- Use
command="back"
to go back to the previous page, orcommand="reload"
to refresh the current page.- Great for testing flows like form submissions and multistep registration.
scroll
The scroll
command simulates scrolling actions either on the whole page or within a specific element.
Parameter | Type | Required | Default | Description |
---|---|---|---|---|
comment |
String | β | - | Description of the scroll action |
type |
String | β | - | Type of scrolling: page for whole page or inner for a specific element |
value |
String | β | - | Value of the scroll (e.g., number of pixels or percentage) |
direction |
String | β | down |
Direction to scroll: up or down
|
measure |
String | β | pixels |
How value is measured: pixels or percent
|
locator |
String | β | - | Locator for the element if type="inner"
|
condition |
Boolean | β | - | Condition to decide if this step should be executed |
locatorStrategy |
String | β | locatorId |
Custom locator strategy if needed (more info in Locators Guide) |
threshold |
Integer (ms) | β | - | Maximum allowed execution time; step fails if exceeded |
<scroll comment="Scroll Down to 90 percent" value="90" direction="down" measure="percent" type="page"/>
-
value="90"
means scroll to 90% of the page height. -
measure="percent"
sets how thevalue
is measured.
β Tip:
Usetype="inner"
if you want to scroll within a specific element on the page (e.g., a long list or table).type="page"
scrolls the entire page.
scrollTo
The scrollTo
command allows you to scroll directly to a specific element on the page.
Parameter | Type | Required | Default | Description |
---|---|---|---|---|
comment |
String | β | - | Description of the scroll-to action |
locator |
String | β | - | Locator ID or strategy for the element to scroll to |
condition |
Boolean | β | - | Condition to decide if this step should be executed |
threshold |
Integer (ms) | β | - | Maximum allowed execution time; step fails if exceeded. |
locatorStrategy |
String | β | locatorId |
Custom locator strategy if needed (more info in Locators Guide) |
<scrollTo comment="Scroll to element" locator="footer.registerButton"/>
-
locator
specifies the element you want to scroll to.
β Tip:
ThescrollTo
command is helpful for bringing an element into view, especially when it's off-screen or hidden within a long page or container.
tab
The tab
command allows you to perform operations with browser tabs, such as switching, closing, or opening new tabs.
Parameter | Type | Required | Default | Description |
---|---|---|---|---|
comment |
String | β | - | Description of the tab action |
index |
Integer | β
(for close or switch ) |
- | Index of the tab to close or switch to. Default is the current tab if not specified |
url |
String | β
(for open ) |
- | URL to open in a new tab. |
condition |
Boolean | β | - | Condition to decide if this step should be executed |
threshold |
Integer (ms) | β | - | Maximum allowed execution time; step fails if exceeded |
<tab comment="Switch to second tab"> <switch index="2"/> </tab>
<tab comment="Close tab with index 2"> <close index="2"/> </tab>
<tab comment="Open a tab via url"> <open url="http://URL"/> </tab>
<tab comment="Close current tab"> <close/> </tab>
β Tip:
- When closing tabs, if
index
is not specified, the current tab will be closed by default.- Use
switch
to easily switch between open tabs based on their index.
switchToFrame
The switchToFrame
command allows you to switch the context to an iframe, either by locator or index.
Parameter | Type | Required | Default | Description |
---|---|---|---|---|
comment |
String | β | - | Description of the action to switch frames |
locator |
String | β | - | Locator ID or strategy for the iframe to switch to |
index |
Integer | β | 0 |
Index of the iframe to switch to (default is 0) |
condition |
Boolean | β | - | Condition to decide if this step should be executed |
threshold |
Integer (ms) | β | - | Maximum allowed execution time; step fails if exceeded |
<switchToFrame comment="Open API frame on the site" locator="frame.page"> <input comment="Add email to the page" locator="frame.email" value="test@gmail.com"/> </switchToFrame>
<switchToFrame comment="Switch to Frame by Index" index="1"> <input comment="Add email to the page" locator="frame.email" value="test@gmail.com"/> </switchToFrame>
- Use
index
to switch to a frame by its index number (default is0
).
β Tip:
When working with multiple iframes, usingindex
is useful if you donβt have a unique locator for the frame. Be mindful of the frame order, starting from index0
.
Assertions and Validation Commands
This section describes commands that help you validate whether elements are present, data is correct, or actions succeed on the page.
assert
The assert
command is used to verify conditions on the page, such as checking if elements are displayed or if data matches the expected value.
Parameter | Type | Required | Default | Description |
---|---|---|---|---|
comment |
String | β | - | Description of the assertion action |
condition |
Boolean Expression | β | - | Condition to decide if this step should be executed |
threshold |
Integer (ms) | β | - | Maximum allowed execution time; step fails if exceeded |
locatorStrategy |
String | β | locatorId |
Custom locator strategy if needed (more info in Locators Guide) |
negative |
Boolean | β | false |
If true , asserts that the expected and actual content do not match |
<assert comment="Check that element is present on the page"> <attribute comment="Assert 'password' field" name="class" locator="registration.inputPassword"> <content>password</content> </attribute> </assert>
π‘ Tips on common attribute names:
innerHTML
: Captures the HTML content inside an element (e.g., button text).value
: Often used for input fields (e.g.,<input value="Test">
).href
: For anchor links (e.g.,<a href="/home">Home</a>
).src
: For image or script sources.data-*
: Custom attributes likedata-id
,data-name
β helpful for dynamic data.class
: Can be used to check if a specific style or state (likeactive
,error
) is applied.β Use attributes to dynamically extract values for assertions, reuse in other steps, or debugging unexpected behavior.
<assert comment="Test for Assert with sub-commands - notEqual, equal, attribute, title"> <attribute comment="Assert 'password' field" name="name" locator="registration.inputPassword"> <content>password</content> </attribute> <title comment="Check whether title of the page is correct"> <content>Default store | Login</content> </title> <notEqual comment="Assert for check that 3 different contents are not equal"> <content>one</content> <content>1</content> <content>{{ONE}}</content> </notEqual> <equal comment="Assert for check that two contents are equal"> <content>one</content> <content>{{one}}</content> </equal> <present comment="Check that element is present on page" locator="forms.save"/> <present comment="Check that element is NOT present on page" locator=".//img[@alt='Sunset in the mountains']" locatorStrategy="xpath" negative="true"/> <checked comment="Check that checkbox is NOT chosen" locator="uiElements.checkbox" negative="true"/> <checked comment="Check that checkbox is chosen" locator="uiElements.checkbox" negative="false"/> <alert comment="Check that alert text is equal to expected content"> <text>Alert!</text> </alert> <alert comment="Check that alert text is NOT equal to expected content" negative="true"> <text>Alert</text> </alert> </assert>
β Tip:
Usenegative="true"
when you expect an element not to match the given condition, such as an element not being present, or an alert message differing from the expected one.
image
The image
command captures a screenshot and compares it to an expected image, validating visual correctness across the page or specific elements.
Parameter | Type | Required | Default | Description |
---|---|---|---|---|
comment |
String | β | - | Description of the image comparison action |
file |
String | β | - | Path to the expected image file to compare against |
highlightDifference |
Boolean | β | false |
Whether to highlight the differences in the comparison (red for mismatched, orange for excluded) |
condition |
Boolean Expression | β | - | Condition to decide if this step should be executed |
threshold |
Integer (ms) | β | - | Maximum allowed execution time; step fails if exceeded |
locatorStrategy |
String | β | locatorId |
Custom locator strategy if needed (more info in Locators Guide) |
-
fullScreen
: Compares the entire screenshot. -
picture
: Compares an image element by its locator. -
part
: Compares a specific part of the page or element.
<image comment="Compare full screen with percentage less than 100" file="compare1.png"> <fullScreen percentage="88"/> </image>
-
percentage="88"
specifies the accuracy for comparing the full screenshot.
<image comment="Compare full screen" file="compare2.png" highlightDifference="true"> <fullScreen/> </image>
- This will highlight differences in red and the excluded zone in orange.
<image comment="Compare full screen with exclude" file="compare3.png"> <fullScreen> <exclude locator="forms.username"/> </fullScreen> </image>
- The
exclude
parameter skips comparing the element specified by the locator.
<image comment="Compare a part of screen with percentage less than 100" file="compare4.png"> <part locator="forms.form" percentage="99"/> </image>
-
percentage="99"
allows for a near-perfect match when comparing only part of the screen.
<image comment="Compare image from the page" file="compare2.png"> <picture locator="image.compare" attribute="src"/> </image>
- This command downloads the image from the page using the
src
attribute of the element found bylocator="image.compare"
, and then compares it pixel-by-pixel with the local image filecompare2.png
. - The
attribute="src"
is used to extract the image URL from the page.
β Tip:
- Image comparison works best with specific elements and smaller portions of the page (use
part
instead offullScreen
for better accuracy).- Ensure consistent screen dimensions when comparing full-page screenshots, as different device sizes can cause mismatches.
Utilities and Enhancements
This section describes commands that provide additional functionalities, such as running custom JavaScript, waiting for elements, and repeating actions.
javascript
The javascript
command allows you to execute custom JavaScript code within the test scenario.
Parameter | Type | Required | Default | Description |
---|---|---|---|---|
comment |
String | β | - | Description of the JavaScript execution |
file |
String | β | - | Path to the file in data containing JavaScript commands to execute |
condition |
Boolean | β | - | Condition to decide if this step should be executed. |
threshold |
Integer (ms) | β | - | Maximum allowed execution time; step fails if exceeded |
<javascript comment="Your comment" file="function.js"/>
- The
file
parameter points to a.js
file somewhere indata
folder with the JavaScript code to execute.
β Tip:
- This command is useful for running custom scripts during your tests (e.g., changing a page's state, interacting with a JS library, or performing calculations).
wait
The wait
command pauses the execution of the scenario for a specified time, allowing certain actions or elements to load before continuing.
Parameter | Type | Required | Default | Description |
---|---|---|---|---|
comment |
String | β | - | Description of the wait action |
time |
Integer | β | - | The time to wait, in either seconds or milliseconds |
clickable |
String | β | - | Wait until a specific element is clickable |
locator |
String | β | - | Locator of the element to wait for |
visible |
String | β | - | Wait until a specific element becomes visible |
unit |
String | β | seconds |
Time unit for time : seconds or milliseconds
|
condition |
Boolean | β | - | Condition to decide if this step should be executed |
threshold |
Integer (ms) | β | - | Maximum allowed execution time; step fails if exceeded |
<wait comment="Wait for 10 seconds or less until element becomes clickable" time="10" threshold="1000"> <clickable comment="Wait for 10 or less seconds until element becomes clickable" locator="login.signIn"/> </wait>
<wait comment="Wait 1 second" time="1000" unit="millis"/>
<wait comment="Wait 10 seconds" time="10000" unit="millis" threshold="500"> <visible comment="Wait for 10 or less seconds until element becomes visible" locator="login.mail"/> </wait>
β Tip:
Usethreshold
to limit the execution time, ensuring the test fails if the element is not found or the action does not complete within the allowed time.
β οΈ Note: Thewait
command is not the same as the globalautowait
setting in your configuration file. Whileautowait
defines the default timeout for all element lookups, thewait
command gives you explicit control over pauses and wait conditions inside the test scenario.
repeat
The repeat
command allows you to repeat any action or sequence of commands multiple times. It is useful for actions that need to be executed a specific number of times or for running actions with different variations.
Parameter | Type | Required | Default | Description |
---|---|---|---|---|
comment |
String | β | - | Description of the repeat action |
times |
Integer | β | - | The number of times to repeat the action (not used with variations) |
variations |
String | β | - | Path to the variations file to run different data (not used with times ) |
condition |
Boolean | β | - | Condition to decide if this step should be executed |
threshold |
Integer (ms) | β | - | Maximum allowed execution time; step fails if exceeded |
<web comment="Start web scripts"> <repeat comment="Check the ability to run variations in repeat" variations="variations_2.csv"> <click comment="Click on registration button" locator="uiElements.register"/> <input comment="Input user email" locator="uiElements.email" value="{{variableFromVariationFile}}"/> <wait comment="Wait for 1 second" time="1"/> </repeat> </web>
- The
variations
parameter allows you to specify a file (like a CSV) that contains data for running the same actions with different inputs.
<repeat comment="Repeat click and wait actions 5 times" times="5"> <click comment="Click on drop-down" locator="uiElements.dropDownField"/> <wait comment="Wait for 2 seconds" time="2"/> </repeat>
- The
times
parameter sets how many times the actions inside<repeat>
should be executed.
β Tip:
- Use
variations
to automate testing with different data sets. - Use
times
to repeat actions multiple times (e.g., for load testing or reliability checks).
include
The include
command allows you to run one scenario inside another, making it easy to bundle multiple scenarios together for reusable actions or tests.
Parameter | Type | Required | Default | Description |
---|---|---|---|---|
comment |
String | β | - | Description of the included scenario |
scenario |
String | β | - | Path to the scenario you want to include |
<include comment="Add scenario for login to the system" scenario="/nameOfScenarioFolderWithSlash"/>
- The
scenario
parameter specifies the path to the scenario from thescenarios
folder that you want to include.
β Tip:
Use theinclude
command to create modular and reusable tests. This allows for easy maintenance of larger test suites by grouping common functionality into separate scenarios.