等到应用程序开始响应 - 如何在 qtp 中对此进行编码?

发布于 2024-09-05 10:23:31 字数 116 浏览 2 评论 0原文

我们有一个应用程序,正在加载一些文件,并且应用程序在加载文件期间停止响应一段时间。在测试自动化期间,我们遇到了自动加载文件的情况,但 qtp 必须等到应用程序再次开始响应。如何编写这个代码?有没有像“等待”这样的属性?

We have an application where some files are being loaded and the application stops responding for some time during the loading of the file. during test automation, we are having the scenario where the file loading is automated, but qtp has to wait until the application starts responding again. How to code this? Any property is there like "Wait"?

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

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

发布评论

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

评论(7

淡淡的优雅 2024-09-12 10:23:31

<块引用>

有像“Wait”这样的属性吗?

如果是这样,那么它是特定于应用程序的,因此要回答这个问题,需要对应用程序的 GUI 设计进行技术研究。

一般来说,考虑一下人类用户如何判断应用程序再次“响应”。通常,会有一些视觉提示,例如出现按钮,或者某个控件不再灰显。使用同步点同步该状态。

如果全部失败(即,如果您无法识别应用程序处理结束时出现、消失或更改其属性的控件),请坚持使用位图检查点,该检查点将寻找与人类可以解释的相同的视觉线索。

通常,在应用程序准备好再次接受输入之前,同步点或视觉提示来得有点太早。然后,如果您的应用程序在预期下一个用户输入之前刷新键盘缓冲区(广泛常见的不良设计的示例......),您将很难正确同步。击键和鼠标点击将丢失。在这种情况下,您应该 a) 通过在下一个输入之前插入延迟(等待函数调用)来解决问题,b) 确定应用程序永远不会刷新其输入队列,c) 强制视觉线索仅在应用程序之后完成真的准备好接受输入了。
当然,b) 和 c) 需要开发人员进行工作,并且在组织上可能难以实现。

如果问题出现在不同的甚至所有的上下文中,请将其传达给测试管理人员,并让他们让开发人员专门为您的测试机器人实现自定义的“就绪”信号。然后,您可以从 QTP 查询该信号。它可以是一个信号量、一个 Windows 字符串属性(Set/GetPropEx API 调用)、一个文件存在(baaad idea..),或其他一些将“就绪”状态从应用程序传递到测试机器人的不危险但不同步的方式。

所有这些听起来很疯狂,但我已经完成了上述所有操作,并且通常取得了良好的结果。

Any property is there like "Wait"?

If so, then it is application-specific, so to answer that one would need to take a technical look at your application's GUI design.

Generally speaking, consider how a human user would figure that the application is "responding" again. Usually, there is some visual hint, like a button appearing, or a some control being not greyed out anymore. Synchronize on that state using a synchronization point.

If all fails (i.e. if you cannot identify a control that appears, disappeares, or changes its properties when application's processing is over), stick to a bitmap checkpoint which would look for the same visual clue a human would interpret.

Often, the synch point or visual hint comes a little too early, before the application is ready to accept input again. Then, if your application flushes the keyboard buffer before the next user input is expected (an example of widely common bad design...), you will have a hard time synchronizing correctly. Keystrokes and mouse clicks will be lost. In this case, you should a) workaround the problem by inserting a delay (wait function call) before the next input, b) establish that the application never flushes its input queue, c) enforce that the visual clue is done only after the app REALLY is ready to accept input.
Of course, b) and c) require work on the developer's side and might be organizationally difficult to implement.

If the problem occurs in different, or even all, contexts, communicate it to test management and let them get the developers to implement a custom "Ready" signal just for your test robot. Then, you could query that signal from QTP. It could be a semaphore, a Windows string property (Set/GetPropEx API call), a file existance (baaad idea..), or some other undangerous yet unsynchroneous way of communicating the "Ready" state from the app to the test robot.

All this sounds crazy, but I've done all of the above, with usually good results.

两人的回忆 2024-09-12 10:23:31

在启用的应用程序对象(例如按钮)上插入同步点。同步点允许您指定超时时间。

Insert a synchronization point on one the application objects, such as a button, being enabled. The synchronization point allows you to specify the timeout period.

探春 2024-09-12 10:23:31

如果您想要快速而肮脏的修复,您可以使用通用的等待(秒)。例如,如果您知道您的应用程序将在不到一分钟的时间内准备好使用。但是,如果它根据数据量而变化,您可以尝试使用应用程序上控件的“Exist”属性,该属性在处理完所有数据后加载。
IE。

while not loaded
wait(1)
loaded = Window.Control.Exist
Wend

You can use a generic Wait(seconds) if you want a quick and dirty fix. For example, if you know that your application will be ready to use in less than a minute. If it varies based on the amount of data however, you could try using the 'Exist' proprty of a control on your application that is loaded once all of the data has been processed.
ie.

while not loaded
wait(1)
loaded = Window.Control.Exist
Wend
幻梦 2024-09-12 10:23:31

在我看来,最简单可靠的解决方案是直接从 user32.dll 调用 WinAPI 的 IsHungAppWindow。 QTP 允许您轻松声明外部函数。

In my opinion, the simplest and reliable solution would be to invoke WinAPI's IsHungAppWindow from user32.dll directly. QTP allows you to declare external functions easily.

嘿嘿嘿 2024-09-12 10:23:31

假设您的应用程序最多需要 2 分钟才能启动。使用下面的函数来了解您的应用程序是否存在...

function checkWindowExistance()

dim i

i=0

for i=0 to 120

if Window.Dialog.Exist

{

       exit for

}

wait(1) 'wait_for_1_second

Next

if i = 120 then

checkWindowExistance = false

否则

checkWindowExistance = true

结束函数

Suppose your application takes maximum 2 min to start. Use function below to know whether your application is exists or not...

function checkWindowExistance()

dim i

i=0

for i=0 to 120

if Window.Dialog.Exist

{

       exit for

}

wait(1) 'wait_for_1_second

Next

if i = 120 then

checkWindowExistance = false

else

checkWindowExistance = true

end function

旧人哭 2024-09-12 10:23:31

等待
等待属性
使页面保持同步等待的主要属性或方法

Sync 这三个是大多数程序员都会使用的

。但是,虽然完整页面需要更好地同步才能使用“.Sync”
它将检查直到同步超时,如果加载成功则进入下一步

但等待等待给定的时间,尽管及时找到对象

Wait
WaitProperty
Sync these three are Main properties or methods that Keeps Page in Synchronized

Wait 'll be used by most of programmers.

But While Complete page need to be snchronized better to use ".Sync"
it 'll check until synchronization time out and it moves to next step if loads successfully

But Wait Waits until given amount of time though object found intime

执笔绘流年 2024-09-12 10:23:31

我们可以使用 While 循环来等待应用程序页面屏幕可见,加载后脚本应继续执行下一个屏幕

We can use While Loop to wait for the Application page screen to be visible, once loaded the script should proceed with the next screen

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