Micro Focus QTP (UFT) Forums
How can I make sure QTP will run all instructions NO skip? - 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: UFT / QTP Beginners (https://www.learnqtp.com/forums/Forum-UFT-QTP-Beginners)
+--- Thread: How can I make sure QTP will run all instructions NO skip? (/Thread-How-can-I-make-sure-QTP-will-run-all-instructions-NO-skip)



How can I make sure QTP will run all instructions NO skip? - farhanalam - 03-13-2009

QTP Version 9.2
Add-Ins Web

Scenario:
In the following code, the QTP executes line #1, and jumps to execute line #2 however the application is still busy in line#1. The Line #2 is skipped and Value2 is not populated in Field 1.

Code 1:
Code:
#1.    Call SelectObject(.WebList("Field 1"), Value1)
#2.    Call SelectObject(.WebList("Field 2"), Value2)

In the following code, wait statement is used to wait for 5 seconds before running the next instruction.

Code 2:
Code:
#1.    Call SelectObject(.WebList("Field 1"), Value1)
#2.    wait(5)
#3.    Call SelectObject(.WebList("Field 2"), Value2)

Using wait statement between instructions at line #2, it works fine.

Issue:
If I remove wait statement from Code 2, sometime line #3 is skipped.
If I use Page.Sync at line #2, it does not do anything.

Question:
1. What is the best way to make sure that line #3 will not be skipped, and it will run regardless on fast or slow machine?
2. What I can use at line #2 instead of using wait (5) statement so that it makes sure line #3 will not execute until line #1 is completed successfully.

Thanks
Farhan


RE: How can I make sure QTP will run all instructions NO skip? - Jackomcnabb - 03-14-2009

Have you tried ".Active" statement in an if statement with a loop (I haven't done this myself for active only for exists so give it a try)

Something Like this

Code:
For i = 1 to 10000
    If SelectObject(.WebList("Field 2"), Value2).Acitive(0) then
       Call SelectObject(.WebList("Field 2"), Value2)
    Exit for
End if
Next