cancel
Showing results for 
Search instead for 
Did you mean: 

Attaching business objects - Best practice?

shahariar_k_bhu
Level 5
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)?
3 REPLIES 3

KedarKulkarni
Level 2
Per the guidlelines document, it is best to recover in the Process, rather than the object. Have a retry counter in the process (say 5), and have a delay (say 10 seconds) in the object action 'Attach'. Whenever an exception related to 'Not running' application is encountered in the Attach action, catch the exception in the process and resume (retry) in the process until you hit the max retries.. This way, you can configure the retry counter to a tolerable limit and not touch the object code/configuration every time you need to make a change to the tolerance limit (for retries).

ShreyansNahar
Level 5
When the new application pops up, what does it look like in the Task manager (what's the process name and the process title)? Like it is a part of Internet explorer, or anything else?

John__Carter
Staff
Staff
Shabu - your attach loop is basically correct:The object 'optimistically' tries to attach, and recovers if there is an exception (because the app is not there yet).Then you pause for say 5 seconds.Then you count how many pauses you have made so far, and decide if you have waited too long.If you have exceeded your limit, throw an exception, otherwise try to attach again.If you increase your limit to 60 seconds it should provide ample time for the app to arrive, and because you are trying to attach every 5 seconds, you won't waste too much time waiting.The Utility - Environment object contains actions like Wait for Process that you could also use, but your method should work.