如何在QTP中测试标签

发布于 2024-07-24 23:22:34 字数 177 浏览 1 评论 0原文

我正在使用 QTP 9.5 测试我编写的应用程序 德尔福。 我安装了 Delphi Add-in 和 QTP 可以识别Delphi控件。 大多数但不是全部, 特别是 TLabel。 QTP无法识别这个 控制并被对象间谍忽略。 关于如何测试标签有什么建议、提示、线索吗?

干杯!

I'm using QTP 9.5 test my application written in
Delphi. I got Delphi Add-in installed and QTP
can identify Delphi controls. Most but not all,
specially TLabel. QTP can not recognize this
control and is being ignored by Object Spy.
Any suggestion, tip, clues how to test labels ?

cheers !

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

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

发布评论

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

评论(4

兰花执着 2024-07-31 23:22:34

您是否尝试过使用 TStaticText 而不是 TLabel?
它们是带有窗口句柄的标签(从 TWinControl 而不是 TGraphicControl 降序),这意味着它们可以从外部获取 Windows 消息。
我猜这是你的问题。 (只是猜测,因为我不知道QTP)

Have you tried with TStaticText instead of TLabel?
They are Labels with a Window Handle (descending from TWinControl instead of TGraphicControl) which means they can get Windows messages from the outside.
I'm guessing that it's your problem. (only a guess as I don't know QTP)

往日 2024-07-31 23:22:34

它可以检测像TSpeedButton这样的控件吗? 如果不是,这可能表明 Qtp 无法检测到从 TGraphicControl 派生的控件,因此没有窗口句柄。

It can detect controls like TSpeedButton? If not, this can be a sign that Qtp cannot detect controls that descend from TGraphicControl and therefore doesn't have a window handle.

帅的被狗咬 2024-07-31 23:22:34

您也许可以为 QTP 编写自己的 Delphi 扩展程序来处理此问题。 您的 QTP 安装路径中应该有一个 pdf 文件:C:\Program Files\HP\QuickTest Professional\help\Extensibility\DelphiExtensibility.chm 和 DelphiExtensibility.pdf。

You may be able to write your own Delphi extender for QTP to handle this. There should be a pdf in your QTP install path: C:\Program Files\HP\QuickTest Professional\help\Extensibility\DelphiExtensibility.chm and DelphiExtensibility.pdf.

不醒的梦 2024-07-31 23:22:34

如果您仍然必须“按原样”测试它,您可能必须采用更硬编码的方式来处理这些控件的父级。

QTP 中的窗口对象通过其方法允许查找包含文本的矩形区域,或单击找到的文本。
如果屏幕上有大量标签的区域,您可以将整个屏幕转储到文本文件并进行文本文件比较。 您还可以在进行比较之前规范化检索到的文本。

这种方法不太稳健,但如果动态计算矩形,并且尽可能不使用硬编码点,则可以改进它。

If you still have to test it "as is" you probably have to go a more hard-coded way addressing the parent of those controls.

A window object in QTP through its methods allows finding a rectangular area containing the text, or clicking on a text found.
If it's an area on the screen with the big amount of labels you can dump a whole screen to the text file and go with the text file comparison. You can also normalize text retrieved before doing comparison.

This approach is less robust but you can improve it if calculating rectangles dynamically, without hard-coding points wherever possible.

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