开发者

How to identify HTML object by it's style in HP QTP?

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!


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.


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
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜