variables Scenario 1 — Loop Over Keyword List Variable
Written by RTILA X Engineering Team
Beginner ~4 min
What You'll Learn
Set and use variables in URLs
Real-World Use Case
Parameterising search queries
LIVE DEMO
Keyword Search Loop
A select-driven search demo iterated by a keyword list variable.
Laptop A
13-inch ultrabook
Laptop B
15-inch workstation
Laptop C
14-inch gaming laptop
EXPECTED OUTPUT
Keyword Results
| title |
|---|
| Laptop A |
| Laptop B |
| Laptop C |
| Phone X |
| Phone Y |
| Phone Z |
| Tablet 1 |
| Tablet 2 |
| Tablet 3 |
RTILA X PROJECT JSON
RTILA X Automation Project
loop-over-keyword-list.json
{
"name": "Loop_Over_Keyword_List",
"settings": {
"urls": [
"https://learn.rtila.com/scenarios/variables/1"
],
"variables": [
{
"is_list": true,
"name": "keywords",
"required": true,
"value": "laptop\nphone\ntablet"
}
]
},
"datasets": {
"keyword_results": {
"item_selector": "css=.keyword-result",
"properties": [
{
"name": "title",
"type": "text",
"selector": "css=.kw-title"
}
]
}
},
"commands": [
{
"command": "for_each",
"params": {
"source_type": "variable",
"variable": "keywords",
"as": "keyword",
"do": [
{
"command": "goto",
"params": {
"url": "https://learn.rtila.com/scenarios/variables/1"
}
},
{
"command": "select_option",
"params": {
"selector": "css=#keyword-select",
"value": "${keyword}"
}
},
{
"command": "wait_for_selector",
"params": {
"selector": "css=.keyword-result",
"iframe": "",
"timeout": 30000
}
},
{
"command": "extract_data",
"params": {
"dataset": "keyword_results"
}
}
]
}
}
]
}
The for_each command iterates over a list variable. Each
keyword becomes the value of ${keyword} inside the loop body
and is appended to the visited URL.
Did you complete this scenario?
Ready to run this automation?
Copy the project JSON above, open RTILA X, create a new project, and paste it.
This scenario covers 1 RTILA X command and is referenced in 2 learning articles.
Continue Learning
Was this helpful?
Thank you for your feedback!