General Commands - TestlumFramework/Testlum GitHub Wiki

General Commands

Welcome to the guide on General Commands in Testlum!
These commands are fundamental building blocks used across all types of testing.


📚 Important Topics

Before diving into individual commands, please review these important concepts:

  • Variations (Dynamic Data)
    Learn how to inject different data sets into your tests using CSV files.

  • Screenshots
    Understand how and when screenshots are captured during test execution.

  • Variables
    Learn how to create, use, and manipulate variables inside your scenarios.

  • Conditions
    Implement logic (if/else) to create flexible and intelligent test flows.

  • Tags
    Organize and filter your scenarios using custom tags for better structure.

🛠️ List of General Commands

Once you're familiar with the concepts above, here are the general-purpose commands available:

Command
wait
migrate
condition
repeat
include
assert

Almost all commands in Testlum have provided attributes:

Attribute Type Required Default Description
comment String true - Comment of step execution for better navigation through test scenario
condition String false - Condition according to which this test step will or won't be executed
threshold Integer false - Parameter, that set maximum allowed test step execution time

wait

Command that pauses the passage of the scenario to perform a certain function that requires a wait. The scenario continues running in the usual way after this command.

<wait comment="Wait for loading new page"
      time="3"
      unit="seconds"/>

Attributes:

Attribute Type Required Default Description
time Integer true - Time to wait in specified units. Seconds by default
unit seconds milliseconds false seconds Unit of waiting time

migrate

Command to migrate dataset within your test scenario.

<migrate comment="Migrate test dataset for MySQL DB" alias="MYSQL_0" name="mysql">
  <dataset>mysql_patch.sql</dataset>
</migrate>

Attributes:

Attribute Type Required Default Description
alias String true - Unique name of database you want to insert data-query
dataset String true - Name of file with dataset you want to migrate (file with dataset has to be stored in data folder)
name mongodb mysql postgres dynamo oracle clickhouse false postgres Name of the database you're using. Default DB is postgres

condition

Command to set up condition for test execution.

<condition comment="if amount of books in store is lower then 25"
           name="DB_RESULT"
           spel="{{BOOKS_AMOUNT}} < 25"/>

Attributes:

Attribute Type Required Default Description
name String true - Name of condition to use in further test steps
spel String true - Boolean expression, has to be created with Spring Expression Language (SpEL)

repeat

Command that allows you to repeat any action used in the commands.

<repeat comment="Repeat 'click' action" times="5">
    <web comment="Start WEB script">
        <click comment="Click on 'Sign In' button" locator="login.signIn"/>
    </web>
</repeat>

<repeat comment="Run variations in repeat" variations="variations_1.csv">
    <web comment="Start WEB scripts">
        <input comment="Input Email Address" locator="forms.email" value="{{email}}"/>

        <input comment="Input Password" locator="forms.password" value="{{password}}"/>
      
        <click comment="Click on 'Sign In' button" locator="login.signIn"/>

        <wait comment="Wait for 1 second" time="1"/>
    </web>
</repeat>

Attributes:

Attribute Type Required Default Description
times Integer false - Is to set the number of repeating (not used with variations)
variations String false - Attribute for the variations file (not used with times)

include

Command that allows you to run a scenario inside a scenario (often used to bundle different scenarios).

<include comment="Include login steps" 
         scenario="/includes/login/scenario.xml"/>

Attributes:

Attribute Type Required Default Description
scenario String true - Path to the scenario you need to launch. Since all scenarios must be stored in 'scenarios' folder, in this parameter you need specify path to your scenario from 'scenario' folder

assert

The <assert> command is used to validate that specific values either match or differ based on your expectations during test execution.

And have 2 options for comparison equal and notEqual

Note: Each equal and notEqual must have at least two <content> elements to compare.

equal

Purpose:

Checks that two or more provided values are equal.

Parameter Required Description
content true (2+ required) Values to compare for equality
<assert comment="Test equal comparison">
    <equal comment="Check if two values are equal">
        <content>one</content>
        <content>{{one}}</content>
    </equal>
</assert>

notEqual

Purpose:
Checks that two or more provided values are not equal.

Parameter Required Description
content true (2+ required) Values to compare for inequality
<assert comment="Test notEqual comparison">
    <notEqual comment="Check if three values are different">
        <content>one</content>
        <content>1</content>
        <content>{{ONE}}</content>
    </notEqual>
</assert>

Tip: General commands are simple yet extremely powerful, allowing you to create dynamic and robust scenarios with ease!

⚠️ **GitHub.com Fallback** ⚠️