QTP如何等待页面加载动态数据? [英] How does QTP wait till the page loads dynamic data?

查看:87
本文介绍了QTP如何等待页面加载动态数据?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个浏览器状态= done,但仍未加载页面的情况. qtp可以等到页面完全加载后,是否有一个通用的程序? 我尝试使用objBrowzer.sync,objPage.Sync,objPage.waitproperty"readyState","completed",50. 但这并不总是有效.

I have a scenario where the browzer status =done but still the page is not loaded. Is there a common procedure where the qtp can wait till the page is fully loaded? I tried with objBrowzer.sync,objPage.Sync,objPage.waitproperty "readyState","completed",50. But it does not work always.

我什至只能等待语句,直到它出现为止.因为在不同情况下,存在不同的对象. 是否有任何适用于所有情况的通用声明?

I cannot even but a wait statement so that it waits till that object appears.because in different cases different objects are present. Is there any common statement that would work in all scenarios?

谢谢.

推荐答案

您刚刚发现,QTP不提供任何与异步浏览器脚本执行同步的显式支持,就像AJAX驱动的网站一样.当QTP认为页面已完全加载时,实际上实际上仍在运行JavaScript处理程序,可能会更新用于页面的HTML,并且QTP会尽早访问GUI.

You just discovered that QTP does not offer any explicit support for synchronizing with asynchronous browser script execution like that of AJAX-driven websites. When QTP believes the page has been fully loaded, there actually are still JavaScript handlers running, possibly updating the HTML used for the page and QTP accesses the GUI to early.

readyState是个好主意,但是通常情况下,很容易找到效果不佳的情况.

readyState is a good idea, but usually, it is easy to find cases where that does not work good enough.

1.最好的解决方案是同步应用程序的忙"指示器,例如进度栏或活动指示器.

1. The best solution is to synchronize on a "busy" indicator of the application, like a progress bar, or activity indicator.

不幸的是,等待忙碌指示符总是表示确实确实出现了忙碌指示符,但是许多应用程序仅在该过程花费足够长的时间(大于2秒等)时才显示一个.然后,这很快变得比预期的更混乱.

Unfortunately, waiting for a busy indicator implies the busy indicator does really appear, always, but many apps show one only if the process takes long enough (longer than 2 seconds, or the like). Then, this quickly becomes a bit messier than expected.

2.如果应用程序没有这样的东西,通常您可以通过同步一些就绪"指示器来帮助自己,例如出现了预期的字段"或确定按钮消失了".如果没有真正的就绪"指示符(通常不存在),这通常需要针对每个上下文的特定解决方案.

2. If the app does not have anything like this, often you might help yourself by synchronizing on some "ready" indicator, like "an expected field appeared", or "The OK button disappeared". This often requires a specific solution for every context if there is no real "ready" indicator (which usually does not exist).

3.在许多项目中,自动化人员可以为他们构建内置于应用程序中的忙碌指示器.虽然这对开发人员并不会造成很多工作(因为现代应用程序具有中央消息分派器,所以忙"到空闲"状态,并且可以轻松地对vv进行集中跟踪),从而大大简化了同步所需的工作量.

3. In many projects, the automation folks can get a busy indicator built into the application just for them. While this does not create a lot of effort for the developers (because modern applications have a central message dispatcher so the transition for "busy" to "idle" state and vv can easily be tracked centrally), it greatly simplifies the amount of work required for synchronization.

因此,如果可能的话,请尝试与开发人员联系,并让他们呈现一个属性(可变的,内存映射的文件,信号量,无论他们喜欢什么),测试机器人的"synch"例程可以轻松地对其进行轮询. (提示:即使在丢失"两个状态之间的繁忙"状态之后,也能够在两个就绪"状态之间进行区分,除了繁忙状态标志"之外,获得顺序的繁忙状态计数"可能也会有所帮助,因此您可能会在同一时间提出要求.)然后,所有同步问题都是应用程序中的一个缺陷,因为它显然无法正确维护就绪信号.

So if possible, try to contact the developers and get them present a property (variable, memory-mapped file, semaphore, whatever they prefer) which the test robot "synch" routine can easily poll. (Hint: To be able to differentiate between two "ready" states even after "missing" the "busy" state between the two, it might be helpful to get a sequential "busy state count" in addition to a "busy status flag", so you might request that on the same occasion.) Then, all synch issues are a defect in the app since it obviously did not maintain the ready signal correctly.

更新对于基于事实上的标准"框架的应用,人们可能会找到以通用方式实现同​​步的方法.

Update For apps that are based on a de facto "standard" framework, one might find ways to implement synchronization in a generic way.

例如,对于JavaScript应用程序,我设法创建了一种将事件流透明地报告给QTP的工具,该工具用于在此等待足够长的时间",从而使人们能够设置类似检查点的特殊库调用,以等待对于某些事件(特别是单击",对于执行AJAX的应用程序将Java Server Pages中的事件"ajaxstop"事件)在继续之前完成.

For example, for JavaScript applications, I managed to create an instrumentation that transparently reports the flow of events to QTP, which is used there to wait "just long enough", enabling one to set special checkpoint-like library calls that wait for certain events (especially "click", and for apps that do AJAX roundtripls a la Java Server Pages, "ajaxstop", events) to be completed before continueing.

这被证明是非常有用的,因为通常情况下,让开发人员实现对测试自动化需求的任何形式的支持非常复杂,并且基于GUI的同步(仅通过测试对象状态/存在)有时是不够的如果应用在后台执行异步请求.它还消除了为每个GUI上下文探索同步选项的需求,这可能非常耗时和/或不可靠.

This has proved to be extremely useful, because often, it is very complicated to get dev to implement any kind of support for test automation needs, and GUI-based synchronization (solely through test object state/existance) sometimes is not enough if the app performs asynchronuous requests in the background. It also eliminates the need to explore synchronization options for each and every GUI context, which can be extremely time-consuming and/or unreliable.

这篇关于QTP如何等待页面加载动态数据?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆