Robot Framework如果元素可见则执行关键字

Pur*_*eni 6 robotframework selenium-webdriver

我有一个页面,可能包含也可能不包含将影响所有xpath的特定元素.

我需要运行"Run Keyword If"来识别这个元素是否存在,如果存在则执行另一个关键字.

我试图将"Page Should Contain Element"和"Element should Be Visible"设置为变量并将其传递给If语句,但它只返回None.

我可以用什么来识别页面中的元素?

Bru*_*ola 21

我遇到了同样的问题,我使用这个解决方案:

${present}=  Run Keyword And Return Status    Element Should Be Visible   id=my-element
Run Keyword If    ${present}    My Cool Keyword
Run Code Online (Sandbox Code Playgroud)