识别QTP内显示的内容

发布于 2024-10-03 01:25:34 字数 633 浏览 0 评论 0原文

我正在尝试使用 QTP 识别框架内显示的内容。 我从页面询问所有与描述匹配的框架并获取框架集合。 我从集合中获取第一帧,但由于某种原因,该对象似乎不存在,因此我无法访问其中显示的内容。 知道如何提取框架内的内容吗?为什么 QTP 不将其识别为现有对象? (备注:我故意不使用存储库来识别框架,因为框架在页面中具有唯一位置,并具有动态索引来识别其位置)

谢谢, 内森

代码说明:

set TargetPage= Browser(...).Page(...)

Set objDesc = Description.Create()
objDesc("micclass").Value = "Frame"
objDesc("html id").Value = "id"
objDesc("html tag").value = "IFRAME"
objDesc("name").value = "id"

set FramesCollection = TargetPage.ChildObjects(objDesc)

Print FramesCollection .count-> Prints a number >0

set firstFrame=FramesCollection(0)
firstFrame.Exist-> Returns False

I am trying to identify the content displayed inside a frame using QTP.
I am asking from the Page all the frames that match the description and get a collection of frames.
I take the first frame from the collection but from some reason it seems that the Object doesn't exist, and therefore I can't reach the content displayed inside.
Any idea how Can I extract the content inside the frame, and why doesn't the QTP recognize it as an an existing object?
(Remark: I intentionally didn't use the repository to identify the frame cause the frame has unique location in the Page with dynamic indexes to identify its location)

Thanks,
Nathan

Code Description:

set TargetPage= Browser(...).Page(...)

Set objDesc = Description.Create()
objDesc("micclass").Value = "Frame"
objDesc("html id").Value = "id"
objDesc("html tag").value = "IFRAME"
objDesc("name").value = "id"

set FramesCollection = TargetPage.ChildObjects(objDesc)

Print FramesCollection .count-> Prints a number >0

set firstFrame=FramesCollection(0)
firstFrame.Exist-> Returns False

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

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

发布评论

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

评论(1

江湖彼岸 2024-10-10 01:25:34

您不能在 ChildObjects 返回的对象上使用 Exist 有关原因的完整说明,请参阅此 博客文章

您应该只使用该对象而不检查它是否存在。如果您想向自己证明该对象实际上已正确找到,您可以使用未记录的 Highlight 方法。

You can't use Exist on an object returned by ChildObjects for a full explanation on why this is see this blog post.

You should just use the object without checking whether it exists. If you want to prove to yourself that the object is actually found correctly you can use the undocumented Highlight method.

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