Robot Framework 如果元素可见则执行关键字
Robot Framework If element is visible execute a keyword
我的页面可能包含也可能不包含会影响所有 xpath 的特定元素。
我需要 运行 一个 "Run Keyword If" 来识别这个元素是否存在,如果存在则执行另一个关键字。
我试图将 "Page Should Contain Element" 和 "Element Should Be Visible" 设置为变量并在 If 语句中传递它,但它只 return None.
我可以使用什么来识别页面中的元素?
我遇到了同样的问题,我使用这个解决方案:
${present}= Run Keyword And Return Status Element Should Be Visible id=my-element
Run Keyword If ${present} My Cool Keyword
我遇到过类似的情况,我使用了下面的脚本:
${IsElementVisible}= Run Keyword And Return Status Element Should Be Visible ${Element1}
Run Keyword If ${IsElementVisible} MyCase1 ELSE Click Element ${Element2}
这是一个更快、更简洁的替代方法:
${c} = Get Element Count ${locator}
Run Keyword If ${c}>0 Call Your Keyword Here
我的页面可能包含也可能不包含会影响所有 xpath 的特定元素。
我需要 运行 一个 "Run Keyword If" 来识别这个元素是否存在,如果存在则执行另一个关键字。
我试图将 "Page Should Contain Element" 和 "Element Should Be Visible" 设置为变量并在 If 语句中传递它,但它只 return None.
我可以使用什么来识别页面中的元素?
我遇到了同样的问题,我使用这个解决方案:
${present}= Run Keyword And Return Status Element Should Be Visible id=my-element
Run Keyword If ${present} My Cool Keyword
我遇到过类似的情况,我使用了下面的脚本:
${IsElementVisible}= Run Keyword And Return Status Element Should Be Visible ${Element1}
Run Keyword If ${IsElementVisible} MyCase1 ELSE Click Element ${Element2}
这是一个更快、更简洁的替代方法:
${c} = Get Element Count ${locator}
Run Keyword If ${c}>0 Call Your Keyword Here