I'm currently working on automating some software in Citrix. We start by launching Internet Explorer, log into a web portal, then launch an application. This application has a process ID that are used in the attach process. So basically, before we can navigate further with this application, it needs to be attached.
I am currently reading if the top root element in application reader is connected. If not, we attach it. However, it takes some time before the application gets launched, so I can't attach it right after I've launched it from Internet Explorer. It can take 30 seconds, 40 seconds etc. before the application is launched.
What is the best practice to handle situations like this? You can't wait for the first screen window, and check if it's exists because you need to attach the window first. I can't launch it either, because the software is not installed on my computer.
I'm currently have a "Recover" stage next to "Navigate - Attach" stage. It logs the attempts made to attach the application. If there are more than 2 attempts, a system exception is thrown. If not, we wait for 15 seconds, then resume. Overall, it works to an extent. However, there may be some cases where the application is launched after 16 seconds, which means that I need to wait 14 more seconds before I can attach it.
How can I handle situations like this? Should I decrease the Wait timer to 10 or 5 seconds, while I increase attempts limit (for example 10 attempts, but 4-5 seconds wait timer)?