# How to wait until the application is running

**URL:** <https://forum.robotframework.org/t/how-to-wait-until-the-application-is-running/4659>\
**Category:** RPA\
**Created:** [6 September 2022 14:40 UTC](https://forum.robotframework.org/t/how-to-wait-until-the-application-is-running/4659 "2022-09-06T14:40:27Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![PatrickZerbinatti](https://avatars.discourse-cdn.com/v4/letter/p/e5b9ba/32.png) [@PatrickZerbinatti](https://forum.robotframework.org/u/PatrickZerbinatti)\
**Post date:** [6 September 2022 14:40 UTC](https://forum.robotframework.org/t/how-to-wait-until-the-application-is-running/4659/1 "2022-09-06T14:40:27Z")

</div>

Hello Guys,

I’m trying to automate a Desktop App using RPA.Windows, and I’m using the following command:  
Windows Run PATH\_TO\_APP

This works fine, the next step is to wait until the app is running to go to the screen and do the process.  
But, I can’t found any good way to wait until the process is running. I know I can use RPA.Desktop and Wait for Element, but I don’t want to use images, just if necessary.  
So, what is a good way to do it?

I already tried using Click from RPA.Windows with some “name”, “class” from multiples parts of the app and I tried to use the Library Process to Run and wait, but I didn’t had sucess.

---

<div class="post-metadata">

**Author:** ![Raivo](https://avatars.discourse-cdn.com/v4/letter/r/df788c/32.png) [@Raivo](https://forum.robotframework.org/u/Raivo)\
**Post date:** [6 September 2022 14:58 UTC](https://forum.robotframework.org/t/how-to-wait-until-the-application-is-running/4659/2 "2022-09-06T14:58:09Z")

</div>

I’ve used WHILE loop to check for window, something like

```python
Wait For Window
    [Arguments] ${title}
    ${is_opened} Set Variable ${False}
    ${failsafe_counter} Set Variable 240
    WHILE not ${is_opened} and ${failsafe_counter} > 0
        ${windows} List Windows
        FOR ${window} IN @{windows}
            ${lines} Get Lines Containing String ${window}[title] ${title}
            ${found_matches} Get Length ${lines}
            IF ${found_matches} > 0
                ${is_opened} Set Variable ${True}
                BREAK
            END
        END
        Sleep 0.5s
        ${failsafe_counter} Evaluate ${failsafe_counter}-1
    END

```

You could add arguments for timeout and sleep to adjust it to you liking.

---

<div class="post-metadata">

**Author:** ![Raivo](https://avatars.discourse-cdn.com/v4/letter/r/df788c/32.png) [@Raivo](https://forum.robotframework.org/u/Raivo)\
**Post date:** [6 September 2022 15:01 UTC](https://forum.robotframework.org/t/how-to-wait-until-the-application-is-running/4659/3 "2022-09-06T15:01:45Z")

</div>

You can also use [Wait For Process](http://robotframework.org/robotframework/latest/libraries/Process.html#Wait%20For%20Process)

---

<div class="post-metadata">

**Author:** ![PatrickZerbinatti](https://avatars.discourse-cdn.com/v4/letter/p/e5b9ba/32.png) [@PatrickZerbinatti](https://forum.robotframework.org/u/PatrickZerbinatti)\
**Post date:** [6 September 2022 16:43 UTC](https://forum.robotframework.org/t/how-to-wait-until-the-application-is-running/4659/4 "2022-09-06T16:43:13Z")

</div>

That While seems a really good way to do it, I will try to use it.  
The Wait for Process I tried, but I didn’t had success, I don’t know why but because the app .exe is on a Network Drive the app returns a error and the Wait for Process says:

> " The process to wait for must have been started earlier with [Start Process](http://robotframework.org/robotframework/latest/libraries/Process.html?_ga=2.92069016.303467618.1662382064-1308143166.1623862440#Start%20Process). If `handle` is not given, uses the current [active process](http://robotframework.org/robotframework/latest/libraries/Process.html?_ga=2.92069016.303467618.1662382064-1308143166.1623862440#Active%20process)."

---

<div class="post-metadata">

**Author:** ![PatrickZerbinatti](https://avatars.discourse-cdn.com/v4/letter/p/e5b9ba/32.png) [@PatrickZerbinatti](https://forum.robotframework.org/u/PatrickZerbinatti)\
**Post date:** [9 September 2022 13:26 UTC](https://forum.robotframework.org/t/how-to-wait-until-the-application-is-running/4659/5 "2022-09-09T13:26:01Z")

</div>

Alright buddy, I was waiting to see if someone had another option, but your code is good, much better then wait for a image of the first page to appears. I just made some changes to adapt to my situations:

```
Wait For Window
  [Arguments] ${window_element} ${value} ${max_iterations}
  ${is_opened} Set Variable ${False}

  WHILE not ${is_opened} and ${max_iterations} > 0
      ${windows} List Windows
      FOR ${window} IN @{windows}
          ${lines} Get Lines Containing String ${window}[${window_element}] ${value}
          ${found_matches} Get Length ${lines}
          IF ${found_matches} > 0
              ${is_opened} Set Variable ${True}
              BREAK
          END
      END
      Sleep 0.5s
      ${max_iterations} Evaluate ${max_iterations}-1
  END

  IF ${max_iterations} == 0
       Fail msg= The ${window_element} == ${value} was not found.
  END

```

Thanks bro!
