如何在HP QTP中通过其样式来识别HTML对象?

发布于 2024-11-27 15:07:56 字数 244 浏览 7 评论 0原文

我有一个网络应用程序和两个具有相同类名(没有 ID)的对象,其他属性也相同。区别仅在于相同的样式属性:其中一个对象具有 "style.display='block'",其他对象具有 "style.display='none'"。 (可能是其他样式属性!)

我如何通过它的样式属性来识别第一个对象?对于这样的名称,我可以使用“attribute/name”,但是样式有类似的东西吗?

谢谢你!

I have a web app and two objects with same class name (no IDs), other attributes also the same. The difference only in same style attributes: one of the objects has "style.display='block'", other has "style.display='none'". (could be other styles attributes!)

How I can identify first object by it's style attributes? For thing such names, I could use "attribute/name", but is there anything like this for style?

Thank you!

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

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

发布评论

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

评论(2

深海夜未眠 2024-12-04 15:07:56

编辑:我最初的答案在当时是正确的,但 UFT 此后添加了对 style/ 属性的支持。您现在可以使用 style/display:=none"


这确实是 QTP 中的一个限制 :(

可以做的一件事是编写一个小型 WebExtesibility 项目来添加显示您的测试对象的属性。

Edit: My original answer was true for its time but UFT has since added support for style/ properties. You can now use style/display:=none".


This is indeed a limitation in QTP :(

One thing you can do is write a small WebExtesibility project which adds the display property to your test object.

不必了 2024-12-04 15:07:56

我知道这是一个老问题,但它被接受,好像没有一个简单的解决方案,虽然有:

是的,你可以,但它必须是实际对象的属性,并且不被父对象继承(好吧,我在这种情况下得到了负面结果)。

' Make a new description for the object
Set desc = Description.Create()
desc("micclass").Value = "WebButton"   ' assuming webbutton here
desc("Class Name").Value = "YourClassName"

' This returns a collection with buttons matching your description
Set Btns = Browser("YourBrowser").Page("YourPage").ChildObjects(desc)

For BtnIndex = 0 to Btns.Count - 1
    ' This will show you the display style, so you can make a selector here
    MsgBox "Button " & BtnIndex & " has display style: " & Btns(BtnIndex).Object.currentStyle.Display
Next

I know this is an old question, but it is accepted as if there is not a simple solution for it, while there is:

Yes you can, but it has to be an attribute on the actual object and not inherited by parent objects (well, I had negative results on that situation).

' Make a new description for the object
Set desc = Description.Create()
desc("micclass").Value = "WebButton"   ' assuming webbutton here
desc("Class Name").Value = "YourClassName"

' This returns a collection with buttons matching your description
Set Btns = Browser("YourBrowser").Page("YourPage").ChildObjects(desc)

For BtnIndex = 0 to Btns.Count - 1
    ' This will show you the display style, so you can make a selector here
    MsgBox "Button " & BtnIndex & " has display style: " & Btns(BtnIndex).Object.currentStyle.Display
Next
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文