В Selenium IDE 3.7.4 Я хотел бы сделать цикл, чтобы кликать по нескольким ссылкам с похожим Xpath.Для этого я думаю, что в создании массива, но попытка с простым массивом с настройками (Command, Target, Value), как показано ниже, не работает.
+----------------+---------------------------------------+---------+
| Command | Target | Value |
+----------------+---------------------------------------+---------+
| execute script | var a = "A|B|C".split("|"); return a; | arr |
+----------------+---------------------------------------+---------+
| execute script | return 0 | counter |
+----------------+---------------------------------------+---------+
| while | ${counter} < 3 | |
+----------------+---------------------------------------+---------+
| echo | "Element = " + ${arr[${counter}]} | |
+----------------+---------------------------------------+---------+
| execute script | return ${counter} + 1 | counter |
+----------------+---------------------------------------+---------+
| end | | |
+----------------+---------------------------------------+---------+
Ожидаемый результат для этого теста будет:
Element = A
Element = B
Element = C
И я получаю этот вывод:
"Element = " + ${arr[${counter}]}
"Element = " + ${arr[${counter}]}
"Element = " + ${arr[${counter}]}
Как я могу обрабатывать массивы и печатать их элементы в Selenium IDE?Я нашел только вопрос здесь относительно этого, но с более старой версией Selenium IDE, в которой были другие команды, такие как getEval
, которых нет в последней версии.
Заранее спасибо за любыесправка.
ОБНОВЛЕНИЕ
Благодаря ответу Джима я смог завершить пример рабочего массива в Selenium IDE.Код как ниже
{
"version": "2.0",
"name": "Array",
"url": "https://www.seleniumhq.org",
"tests": [{
"name": "Untitled",
"commands": [{
"command": "open",
"target": "https://www.seleniumhq.org",
"targets": [],
"value": ""
}, {
"command": "executeScript",
"target": "var a = \"projects|download|documentation\".split(\"|\"); return a;",
"targets": [],
"value": "arr"
}, {
"command": "executeScript",
"target": "return 0",
"targets": [],
"value": "counter"
}, {
"command": "pause",
"target": "4000",
"targets": [],
"value": ""
}, {
"command": "while",
"target": "${counter} < 3",
"targets": [],
"value": "counter"
}, {
"command": "executeScript",
"target": "return \"css=#menu_\" + ${arr}[${counter}] + \" > a\";",
"targets": [],
"value": "output"
}, {
"command": "click",
"target": "${output}",
"targets": [],
"value": ""
}, {
"command": "pause",
"target": "3000",
"targets": [],
"value": ""
}, {
"command": "executeScript",
"target": "return ${counter} + 1;",
"targets": [],
"value": "counter"
}, {
"command": "end",
"target": "",
"targets": [],
"value": ""
}]
}],
"suites": [{
"name": "Default Suite",
"persistSession": false,
"parallel": false,
"timeout": 300,
"tests": ["78b402ba-8dfa-47d6-bee8-7a0d928db6f1"]
}],
"urls": ["https://www.seleniumhq.org/"],
"plugins": []
}