Ask a Question

If ... then else statements

Champion Level 0

If ... then else statements

Hi All,


anyone who can help me?


im hoping its simple but im new to smartbear ( and automation testing) so suggestions are much welcomed.


all i am wanting to do is to run either a If ... Then / Else or a loop where a button is clicked until a pop up screen arrives, then once the pop up screen arrives then continue the test (the pop up will usually arrive withing around 5 clicks of the button)


what is the best way of doing this?


image is attached, but i simply want Click btnPick to repeat until wndOK is visible


Thanks in advance!!


Champion Level 3

What did you try and what happened when you did that?


There are several ways you can set this up, but the more information you give us, the better we can help you.

okay so....


as you can see in the images i want to repeat the action "btnPick - Click Button" (blue) until "dlgInformation" pop up is visible and then continue going down the test steps.


2019-01-07 08_39_54-Create Despatch Note - 1000236_1.png



2019-01-07 08_38_43-Window.png

2019-01-07 08_53_09-Window.png


i did look into the If..then action but it simply clicked the "btnPick" button once and then was searching for the "dlgInformation" screen and then failed as it was not visible.


like i say i am new to this so any tips are much appreciated. any other info let me know.


from this example usually it would pick the first one anyway but sometimes an item could be on the list which could not be picked on this despatch (due a service/already picked but not despatched for another job etc) so clicking "btnPick" again would select the next one down and so on


You can use For Loop to n  times you wanted to click.




When you're done with adding above dialog create button click action put it in Foor Loop then you are all set.


You will see a screen like below (Instead Log you will button lick)



Shankar R

LinkedIn | CG-VAK Software | Bitbucket |

“You must expect great things from you, before you can do them”

Extension Available

Esteemed Contributor

To expand on @shankar_r's answer... the for loop is what you would do for repeatedly clicking on the button.  Each time through the loop, click the button.  Then use an "if-object" operation to check to see if the popup exists.  If it does, if this was script code, I'd call a "break" in the for-loop.  However, since it is not script code, break is not available so I would set the index of the for-loop to be equal to the upper range so that the loop would exit.

Robert Martin
[Hall of Fame]
Please consider giving a Kudo if I write good stuff

Why automate?  I do automated testing because there's only so much a human being can do and remain healthy.  Sleep is a requirement.  So, while people sleep, automation that I create does what I've described above in order to make sure that nothing gets past the final defense of the testing group.
I love good food, good books, good friends, and good fun.

Mysterious Gremlin Master
Vegas Thrill Rider
Extensions available
Valued Contributor



You really should use script but you could do that my keyword test.

In my example it loops in the notepad until the text "test" is written.

In you case, it has to loop until the "visible" of your popup is true.

Make a namemapping of your popup, and in the "while loop" statement use "code expression" and paste your object.visible in the Value1, then "not equal", then "true" in the value 2.

if you need, put a delay of 1 or 2 seconds to let the popup appears.

then after the Delay (outside the while loop) paste the keyword test step in wich you click on the popup.



SmartBear Alumni (Retired)

Guys, thanks for your replies.

@Jakemorley, did any of the given suggestions help you?

Tanya Yatskovskaya
SmartBear Community and Education Manager

It Has Worked!! Thank You @Marsha_R@shankar_r@tristaanogre@m_essaid@TanyaYatskovska


i've attached the test steps for you to see which suggestion worked.


Much appreciated all round



SmartBear Alumni (Retired)

Hi Jake,


Great to hear this. Happy testing 🙂

Tanya Yatskovskaya
SmartBear Community and Education Manager

Showing results for 
Search instead for 
Did you mean: