Highlighted
Absent Member.
Absent Member.
275 views

Which one will give better performance in UFT, by using Set or by using With

Which one will give better performance in UFT, by using Set or by using With. Check below code 

Which one will be better 1) with or 2) Set 

With Window(“Flight Reservation”)
For i=1 to 1000
.WinEdit(“Name:”).Set “QTP”
Next
End With

OR 

Set myObj = Window(“Flight Reservation”).WinEdit(“Name:”)

For i=1 to 1000
myObj.Set “QTP”
Next

 

 

 

0 Likes
1 Reply
Highlighted
Super Contributor.. Super Contributor..
Super Contributor..

These comparisons are not equal so there is no better as they are different concepts.  Neither of these will really net you better performance (neglible) though you're welcome to try it and post your results.

I personally can't stand With statements b/c it can be tough to trace down the right parents in large With blocks with other mixed OR parents (I remove them when I see them).

Set is passing a object reference which most use quite frequently.  In your example, I woud not use either since there's only one function call so it's an unnecessary step.  In cases where you're doing lots of functions against that object, then Set can be a good option assist in readability/accessibility/management of your script.

0 Likes
The opinions expressed above are the personal opinions of the authors, not of Micro Focus. By using this site, you accept the Terms of Use and Rules of Participation. Certain versions of content ("Material") accessible here may contain branding from Hewlett-Packard Company (now HP Inc.) and Hewlett Packard Enterprise Company. As of September 1, 2017, the Material is now offered by Micro Focus, a separately owned and operated company. Any reference to the HP and Hewlett Packard Enterprise/HPE marks is historical in nature, and the HP and Hewlett Packard Enterprise/HPE marks are the property of their respective owners.