【发布时间】:2021-04-19 00:55:08
【问题描述】:
我正在努力使用 Selenium 在机器人框架中创建一个测试用例。 基本上我的目标是使用一些 xpath 查询在 FOR 循环中捕获一些 web 元素,检查页面上存在的实际 web 元素,以防下一个不通过。 我创建了以下脚本:
*** Test Cases ***
FOR ${href} IN @{hrefs}
Log ${href}
${pl}= Run Keyword And Continue On Failure Get Element Count xpath://a[contains(@href,'test')]
${photo_link}= Run Keyword If ${pl}> 0 Get WebElement xpath://a[contains(@href,'test')]
${test_a}= Set Variable ${photo_link.get_attribute('innerHTML')}
ELSE
${test_a}= do something else
END
Close All Browsers
但我总是出错:
'Else' is a reserved keyword. It must be in uppercase (ELSE) when used as a marker with 'Run Keyword If'.
检查文档我找不到任何解决方案。 我使用了错误的语法吗? 有没有其他方法可以避免和跳过不匹配的“Get WebElements”? 谢谢
【问题讨论】: