QTP:JavaScript 同步

发布于 2024-09-11 03:02:32 字数 212 浏览 1 评论 0原文

有一个框架,其内容由 JavaScript 加载。

<iframe ... onload="pageLoaded();">

QTP 测试需要等待加载完成。框架内容可能会根据用户设置而有所不同,因此检查框架中元素是否存在不是一个选项。

有没有办法在 QTP 中等待,直到加载所有内容,而不尝试检查某些元素是否存在?

There is a frame which content is loaded by a javascript.

<iframe ... onload="pageLoaded();">

A QTP test needs to wait until it finishes loading. The frame content can differ basing on user settings, so checking for existense of an element in the frame is not an option.

Is there a way to wait in QTP until all content is loaded without trying to check for existence of some element?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

心奴独伤 2024-09-18 03:02:32

有几种方法:

最简单的一种,在页面对象上使用隐藏的同步方法:

oPage.sync    ' Where oPage is your page object

如果这不起作用,您可以获取浏览器对象的 wait 属性:

if oBrowser.WaitProperty("state", micRegExpMatch("4|complete"), 60 * 1000) then
    msgbox "Browser is ready!"
else
    msgbox "Even after 1 minute, the browser is not ready :("
end if

或者,您可以获取状态栏、文本,看看是否有是其中的文本“Waiting”(仅限 IE)

Set oStatusBar = Browser("micclass:=Browser").WinStatusBar("nativeclass:=msctls_statusbar32")
Do : Loop Until instr(oStatusBar.GetROProperty("text"), "Waiting") = 0

或进度条:(

Set oProgressBar = Browser("micclass:=Browser").WinObject("nativeclass:=msctls_progress32")
Do : Loop Until oProgressBar.getROproperty("visible")

代码已简化。正如您所知,QTP,您必须在访问对象和属性之前检查它们是否存在。)

A few ways:

The most simple one, use the hidden sync method on the page object:

oPage.sync    ' Where oPage is your page object

If this don't work, you can get the wait property of your browser object:

if oBrowser.WaitProperty("state", micRegExpMatch("4|complete"), 60 * 1000) then
    msgbox "Browser is ready!"
else
    msgbox "Even after 1 minute, the browser is not ready :("
end if

Alternatively you can get the statusbar, the text and see if there is the text "Waiting" in it (IE only)

Set oStatusBar = Browser("micclass:=Browser").WinStatusBar("nativeclass:=msctls_statusbar32")
Do : Loop Until instr(oStatusBar.GetROProperty("text"), "Waiting") = 0

Or the progressbar:

Set oProgressBar = Browser("micclass:=Browser").WinObject("nativeclass:=msctls_progress32")
Do : Loop Until oProgressBar.getROproperty("visible")

(Code is simplified. As you know QTP, you have to check on the existence of the objects and properties before accessing them.)

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文