Return reusable object - Printable Version +- Micro Focus QTP (UFT) Forums (https://www.learnqtp.com/forums) +-- Forum: Micro Focus UFT (earlier known as QTP) (https://www.learnqtp.com/forums/Forum-Micro-Focus-UFT-earlier-known-as-QTP) +--- Forum: VB Scripting/Descriptive Programming (https://www.learnqtp.com/forums/Forum-VB-Scripting-Descriptive-Programming) +--- Thread: Return reusable object (/Thread-Return-reusable-object) |
Return reusable object - HelenN - 04-20-2011 I am using QTP 11, and can't find a solution to using relative window locations that can vary in swfname values and number of SwfWindows. I am using an application that reuses windows within it, and am trying to use the With statement to reduce duplication. However, as the With statement can vary for each end window I tried to define the returned object in a function, but found that I could not set an object unless I knew the number of SwfWindows to be used. Is there a way to do this? So far the only way I can get it to work is to define the cases for the With statement in every action and repeat the code under it as the with statement must have the End With in the case and not just be started in a case - meaning that I am not producing code that is easy to maintain. Is there another statement that is more flexible? An example of the problem is: Window z can be accessed from the child of window a, b, and from the child window of a and c, d, so the With statement could be: Code: With SwfWindow("swfname:=a").SwfWindow("swfname:=b").SwfWindow("swfname:=z") .SwfButton("swfname:=btnOK").Click Any help is appreciated as I am sure there must be an easier way to create maintainable code! |