If loop with Assert

Hi, I have a login test case where I need to check 3 tickboxes. I have set the current script to click on them to check the blank boxes. However in the event of a failed login, chrome saves cache and the boxes remain ticked when continuing testing for the next user. Thus due to Click function the script will result in unchecking the boxes when testing the next user.

I have tried to use the check and uncheck commands for this but KR says it is not a toggle switch. Thus I am trying to use an if loop such that if there is an error message upon login due to the boxes being unchecked, it will go back and tick the boxes. Trying to create an assertElementPresent for the error message and put it into an if loop, but am struggling with how to do so. Would appreciate any help. Thanks!

One idea is to us storeText to store the error message in a variable. If the error message is fixed, you can compare the variable with that and toggle only if it matches.

Please view the sample test case I prepared and see if it helps!

verify if text matches expectation.krecorder.zip (1.7 KB)

You can change sampleText to another text to verify that the if statement is actually directing the execution flow.

1 Like

Thanks a lot! storeText works so I can now compare the error message and direct it to check accordingly. Thanks

1 Like