Home > Mobile >  Robot Framework : Selenium Library (Eclipse) - How to Use Run keyword if
Robot Framework : Selenium Library (Eclipse) - How to Use Run keyword if

Time:06-09

I wanted to know how I can use keyword "run keyword if" for my script. For Context, my webpage has a graph that shows if users have been connected and if no users are connected it shows a "No data Found" image. So, i want to use "run keyword if" with "Page should contain Element Locator" for the graph. if it passes , well and good, if not, I want to use "ELSE Page should contain element Locator" for the no data found image. So, how do I go on about achieving this?

CodePudding user response:

By combining it with Run Keyword And Return Status - your want to first check for one of the conditions, the most probable - say it's the graph being present; and if it's not, then check for the other case:

${graph shown}=    Run Keyword And Return Status     Page should contain Element    Locator_graph
Run Keyword If     not ${graph shown}   Page should contain Element    Locator_no_data
 

BTW if you're using Robot Framework v5 and up, you can use IF instead of Run Keyword If

  • Related