Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Is there any Sync function to AJAX frames?
#1
Solved: 11 Years, 3 Months, 4 Weeks ago
Hi !

I have a problem on my scripts about wait time to load pages.
Ok, I use the function Brownser(xxx).Page(xxx).Sync to make the QTP wait the page load completely. But I am testing a webpage in C#, with some frames in AJAX.

There are some process in the webpage, that doesn`t load the page, but the frame loads. What I mean is that the page will not refreshed, but the system will take some seconds to load some information in the AJAX frame.

I was using the WAIT() function to these cases, but it`s terrible because the wait time for the frame is always changing. I am using like Wait(15), it's too much time.

So pleeease.... is there anyone able to help me with this issue? I was thinking maybe there is a function on the QTP like:
Brownser(xxx).Frame(xxx).Sync.... but I guess not, heheheh...

I am not sure if I was clear, sorry... I hope yes! Smile


Thank you very much !!!
Reply
#2
Solved: 11 Years, 3 Months, 4 Weeks ago
There are several ways to do dynamic waits for AJAX calls. It all depends on what is changing on the page. For example, sometimes an object exists on the page, but is just hidden, either by having coordinates off the visible area, or by having a height and width of 0, or by having the visible property set to false. Otherwise, objects can be inserted into the DOM via an AJAX call. All of these scenarios require different code. The following examples are registered functions so that they can be called on a WebElement directly. To illustrate waiting for a specific object to have a height and width greater than 0 (thereby making the object visible):

Code:
'@Description Waits until the test object has width and height greater than zero, pass Null for timeout to accept default of 10 seconds.
Public Sub WaitForVisibility(test_object, ByVal timeout)
    If IsEmpty(timeout) Or IsNull(timeout) Then timeout = 10 End If
    Dim start: start = Timer    
    Do While (test_object.GetROProperty("width") <= 0 And test_object.GetROProperty("height") <= 0) And (Timer - start < timeout)
        Wait 0, 500
        test_object.Init
    Loop
    Wait 0, 500
End Sub
RegisterUserFunc "WebElement", "WaitForVisibility", "WaitForVisibility"

To wait for the existence of an object:

Code:
'@Description Waits until the test object exists, pass Null for timeout to accept default of 10 seconds.
Public Sub WaitForExistence(test_object, ByVal timeout)
    If IsEmpty(timeout) Or IsNull(timeout) Then timeout = 10 End If
    Dim start: start = Timer    
    Do While (Not test_object.Exist(0)) And (Timer - start < timeout)
        Wait 0, 500
        test_object.Init
    Loop
    Wait 0, 500
End Sub
RegisterUserFunc "WebElement", "WaitForExistence", "WaitForExistence"
Reply
#3
Solved: 11 Years, 3 Months, 4 Weeks ago
Thank you very much man !!

You cleared my mind, and I could solve the problem.

Thank you very much. Big Grin
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Calling a Function in Function Library when function is defined in an Action jitenderkkr 0 2,973 11-27-2014, 12:53 PM
Last Post: jitenderkkr
  Testing web Application that makes AJAX calls pendri 2 3,935 05-24-2011, 02:36 PM
Last Post: surya_7mar
  How can I fetch server time using function Now or any other function? blanchedsouza 2 5,115 11-07-2009, 08:34 PM
Last Post: Ankur
  Ajax calandar rajaselvan.d 0 1,811 05-08-2009, 01:36 PM
Last Post: rajaselvan.d

Forum Jump:


Users browsing this thread: 1 Guest(s)