Robot Framework If element is visible then execute keyword

I have a page that may or may not contain a specific element that will affect all xpaths.

I need to run "Run if keyword" to determine if this element exists, and if needed to execute another keyword.

I tried to set "Page must contain element" and "Element must be visible" as variables and pass it in the If statement, but it only returns None.

What can I use to identify an element on a page?

+3


source to share


2 answers


I faced the same problem, I am using this solution:



${present}=  Run Keyword And Return Status    Element Should Be Visible   id=my-element
Run Keyword If    ${present}    My Cool Keyword

      

+12


source


I had a similar situation and I used below, Hope below helps:



            ${IsElementVisible}=  Run Keyword And Return Status    Element Should Be Visible   ${Element1}
            Run Keyword If    ${IsElementVisible}  MyCase1  ELSE  Click Element  ${Element2}

      

0


source







All Articles