计算表达式 '[<selenium.webdriver.remote.webelement.WebElement... 错误

Evaluating expression '[<selenium.webdriver.remote.webelement.WebElement... error

我正在尝试验证演练弹出窗口,每次关闭时我都会执行此关键字以再次打开它,但是如果我多次执行它会失败并出现错误。语法是正确的,因为我能够在其他 TC 中执行 2-3 次。谁能帮助我了解问题出在哪里?

Open Walkthrough Guide If It is Closed
${ELEMS}=    Get WebElements    ${WELCOME_POPUP}
Run Keyword If    ${ELEMS} == @{EMPTY}    Run Keywords
...    Execute Javascript    localStorage.setItem('peopleAnalyticsTourDismiss', 'false')
...    AND    Reload Page

错误代码

Evaluating expression '[<selenium.webdriver.remote.webelement.WebElement (session="461c3d8d360e2040589b1f70653b326d", element="3de37e69-02bd-4b76-8ff0-1bd652b952d7")>] == []' failed: SyntaxError: invalid syntax (<string>, line 1)

如果 运行 一个关键字如果 ${ELEMS} 是一个空列表,我建议这样写:

Run keyword if  len($elems) == 0  ...

原因是,在表达式中 ${ELEMS} 不是元素列表,而是元素列表的字符串表示形式。使用 $elems 是一种在表达式中使用实际对象的方法。

来自文档:

When a variable is used in the expressing using the normal ${variable} syntax, its value is replaced before the expression is evaluated. This means that the value used in the expression will be the string representation of the variable value, not the variable value itself.

此语法包含在 BuiltIn library, in the section titled Evaluating expressions

的文档中