# How to use IF command and WHILE command

**URL:** <https://forum.katalon.com/t/how-to-use-if-command-and-while-command/11154>\
**Category:** Web Testing\
**Tags:** katalon-recorder\
**Created:** [May 24, 2018, 8:35pm UTC](https://forum.katalon.com/t/how-to-use-if-command-and-while-command/11154 "2018-05-24T20:35:43Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![bahadir\_kurt](https://avatars.discourse-cdn.com/v4/letter/b/b4bc9f/32.png) [@bahadir\_kurt](https://forum.katalon.com/u/bahadir_kurt)\
**Post date:** [May 24, 2018, 8:35pm UTC](https://forum.katalon.com/t/how-to-use-if-command-and-while-command/11154/1 "2018-05-24T20:35:43Z")

</div>

Hi,

In my test, the website I used has radio buttons. When you push a radio button, it brings a text value to the screen and I am storing that value inside a variable by using “storeSelectedValue” command.

Then I want to use that variable inside the IF command and according to its True or False value, I want to open a new website. At this point how can I use IF command? I selected IF command from the drop down menu and it asks Target and Value for that. I know programming and wanted to try IF(myVariable = blabla) but not sure this is the correct way. Could you give me an example on Katalon Automation Recorder?

My last question is how can I put those statements inside a loop? I mean I want to do the same statements forever.

Thanks already.  
Bahadir

---

<div class="post-metadata">

**Author:** ![bahadir\_kurt](https://avatars.discourse-cdn.com/v4/letter/b/b4bc9f/32.png) [@bahadir\_kurt](https://forum.katalon.com/u/bahadir_kurt)\
**Post date:** [May 24, 2018, 10:40pm UTC](https://forum.katalon.com/t/how-to-use-if-command-and-while-command/11154/2 "2018-05-24T22:40:33Z")

</div>

Ok I found it, I used IF command and in Target section I used storedVars[‘myVariable’] = ‘blablabla’ and in Value part, I used true (just write the word “true”)  
Then I entered my other commands and after that I finished it by ENDIF command.

Same for WHILE loop, I used command WHILE and Target section 1 == 1 and Value section true

Now I need something new:  
How can I maket it wait after o command executed, like sleep() in programming or wait() or delay()  
It should be set up in terms of seconds as parameter.

Thanks already,  
Bahadir

---

<div class="post-metadata">

**Author:** ![Apb\_Cee](https://avatars.discourse-cdn.com/v4/letter/a/35a633/32.png) [@Apb\_Cee](https://forum.katalon.com/u/Apb_Cee)\
**Post date:** [May 30, 2018, 7:48am UTC](https://forum.katalon.com/t/how-to-use-if-command-and-while-command/11154/3 "2018-05-30T07:48:33Z")

</div>

> How can I maket it wait after o commandexecuted, like sleep() in programming or wait() or delay()  
> It should be set up in terms of seconds as parameter.

WebUI. **delay** (1)  
1 means 1 second.  
Cf [doc](https://docs.katalon.com/display/KD/%5BWebUI%5D+Delay).

---

<div class="post-metadata">

**Author:** ![bahadir\_kurt](https://avatars.discourse-cdn.com/v4/letter/b/b4bc9f/32.png) [@bahadir\_kurt](https://forum.katalon.com/u/bahadir_kurt)\
**Post date:** [June 14, 2018, 6:49am UTC](https://forum.katalon.com/t/how-to-use-if-command-and-while-command/11154/4 "2018-06-14T06:49:02Z")

</div>

Thank you very much

---

<div class="post-metadata">

**Author:** ![devalex88](https://dub1.discourse-cdn.com/katalon/user_avatar/forum.katalon.com/devalex88/32/336_2.png) [@devalex88](https://forum.katalon.com/u/devalex88)\
**Post date:** [June 25, 2018, 4:27am UTC](https://forum.katalon.com/t/how-to-use-if-command-and-while-command/11154/5 "2018-06-25T04:27:07Z")

</div>

We have a “Delay” example at [https://github.com/katalon-studio/katalon-recorder-samples](https://github.com/katalon-studio/katalon-recorder-samples).
