\ Run Keyword If ${i} == 7 log to console Testing Variant 1
\ ${is visible}= Run Keyword And Return Status Element Should Be Visible (//li[@class='_8HqL0'])[${i}]
\ Run Keyword If ${is visible} Run keywords
\ ... Scroll Element Into View (//li[@class='_8HqL0'])[${i}]
\ ... AND Click Element (//li[@class='_8HqL0'])[${i}]
\ ... AND sleep 2s
\ ... set variable ${Ad_Path} Get Text //*[@class='rui-3blDo _1Uh38 _27AdP']
\ ... AND log to console ${Ad_Path}
Hi i want to use the GET TEXT activity inside a IF block in FOR but its giving an error stating keyword name cannot be empty help
You can't have a construct ${variable}= Returned Value From Keyword inside a Run Keyword/Run Keyword If because the latter expects everything passed to it to be a keyword - and it considers ${variable} also to be one.
There is one "workaround" - Run Keyword If propagates back up the last returned value in its keyword, and that can be set to a variable. E.g. you can do this:
${variable}= Run Keyword If ${condition} Returned Value From Keyword ELSE Set Variable other value
Mind the ELSE in this construct - without it, if the condition is false the variable will be undefined - will be left with a value None (the data type).
Naturally, if the Run Keyword If has more than one steps (like your console logs) you'll have to break it up - a block that "does things", and another (or others) that "assigns values".
I've typed "workaround" in quotes because it isn't really such - it's the way the keyword is designed to be used.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With