问题
I'm using SikuliLibrary with RobotFramework for automating windows desktop application. One case is like: sometimes you need to put login credentials sometimes not, So I have to apply if else condition for SikuliLibrary with RobotFramework? I mean if login screen appear then will put credentials otherwise not. as it is image based So, I'm unable to apply if else condition.
回答1:
You could have the login executed unconditionally, in a Run Keyword And Ignore Error block, and continue if it (the login) wasn't present:
${rc} ${msg} Run Keyword And Ignore Error Do Sikuli Login
Run Keyword If "${rc}" == 'FAIL' and "${msg}" != 'the expected message when the login was not present'
... Fail The Login keyword failed unexpectedly: ${msg}
Naturally, this would be useful only if the login must/may happen at certain points in your scenarios, not on semi-random basis (it's not clear to me isn't it the latter from your question).
Disclaimer: I've never used RF with Sikuli, only each by itself - can be totally off the mark here.
来源:https://stackoverflow.com/questions/53543243/how-to-apply-if-else-condition-for-sikulilibrary-with-robotframework