Qtp waits for Ajax Testing

Source: Internet
Author: User

Ajax has been widely used. When using qtp to test Ajax applications, you often encounter the need to wait for Ajax operations to complete data loading. Relevantcodes.com's "qtp: synchronization for Ajax Applications" article describes how to encapsulate an ajaxutil object to handle these problems in a unified manner:

Http://relevantcodes.com/qtp-synchronization-for-ajax-applications/

 

 

The following is an example of using the ajaxutil object:

Systemutil. Run "iexplore.exe", "www.kayak.com"

 

If not browser ("title: = cheap flights. *"). exist (10) Then exittest

 

Ajaxutil. objectsync = 30 'check if the added objects exist before we synchronize

Ajaxutil. statussync = 10' wait for a max 10 seconds if there is no status change

 

'Add objects to collection (its mandatory that you add objects to the class)

Ajaxutil. addobject "mybrowser1", browser ("title: = cheap flights .*")

Ajaxutil. addobject "mytable", browser ("title: = kayak.com search results ")_

. Webtable ("innertext: =. * Of. * roundtrips shown. * |. * forget all. *", "index: = 0 ")

Ajaxutil. addobject "mybrowser2", browser ("title: = kayak.com search results ")

 

Browser ("title: = cheap flights. *"). webedit ("html id: = destination ")_

. Set "Atlanta, Ga-Hartsfield-Jackson (ATL )"

 

'Its mandatory that you set a browser for which you will run the test for changes in Elements

Ajaxutil. setbrowser "mybrowser1" 'required step

 

'Synchronize for changes in objects:

Ajaxutil. syncobjects "webelement"

 

Browser ("title: = cheap flights. *"). webbutton ("html id: = fdimgbutton"). Click

 

'You can modify the objectsync and statussync times here for the next operations.

'Example: statussync is increased

Ajaxutil. statussync = 15 'crease the statussync

 

'Synchronize with the flights table

Ajaxutil. syncwebtable "mytable"

 

'Test complete-release dictionary

Ajaxutil. destroydict

 

 

 

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.