QTP:我们如何捕获在单选按钮上进行鼠标悬停时显示的工具提示文本?

发布于 2024-12-16 21:29:32 字数 875 浏览 4 评论 0原文

我正在尝试使用 GetROProperty 通过描述性编程捕获将鼠标悬停在单选按钮上时显示的文本。如果我发现显示的工具提示文本,它会被识别为 WebElement。我尝试执行下面的代码

setToolTip=Browser(strBrowser).Page(strPage).WebElement(strwebElement).GetROProperty("innertext")
MsgBox ToolTip

,但收到以下错误消息

“无法识别(WebElement 类的)对象“[WebElement]。验证该对象的属性是否与应用程序中当前显示的对象匹配”。

如果我通过将对象添加到对象存储库来运行相同的代码,我可以使用 GetROProperty 捕获工具提示文本

除了 GetROProperty 之外还有其他属性吗?可以捕获工具 文本或有其他方式吗?

显示提示

我的完整代码看起来像这样,但仍然存在相同的问题,

Browser(strBrowser).Page(strPage).WebRadioGroup(strLogicalName).Select "true"
Browser(strBrowser).Page(strPage).WebRadioGroup(strLogicalName).FireEvent "onmouseover"
set ToolTip=Browser(strBrowser).Page(strPage).WebElement("strWebElement").Object.title

MsgBox ToolTip

谢谢

I am trying to capture the text displayed on doing mouse over on a radio button with Descriptive Programming using GetROProperty. If I spy the tool tip text displayed, it is recognizing as WebElement. I tried executing the below code

setToolTip=Browser(strBrowser).Page(strPage).WebElement(strwebElement).GetROProperty("innertext")
MsgBox ToolTip

but i am getting the below error message

"Cannot identify the object "[WebElement] of (of class WebElement.Verify that this Object's properties match an object currently displayed in your application".

If I run the same code by adding the objects to Object Repository I am able to capture the tool tip text using GetROProperty

Is there any other property other than GetROProperty so that I can capture the tool tip text displayed or is there any other way?

Please suggest.

My complete code looks like this. I have also tried the "object.tile" as suggested but still the same Issue.

Browser(strBrowser).Page(strPage).WebRadioGroup(strLogicalName).Select "true"
Browser(strBrowser).Page(strPage).WebRadioGroup(strLogicalName).FireEvent "onmouseover"
set ToolTip=Browser(strBrowser).Page(strPage).WebElement("strWebElement").Object.title

MsgBox ToolTip

Please suggest

Thanks.

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

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

发布评论

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

评论(1

平生欢 2024-12-23 21:29:32

本机工具提示实际上是 HTML 元素的 title 属性,因此为了获取元素的标题,您可以执行 Browser("a").Page("b").WebElement(" c").Object.title

然而,从您的描述来看,您的问题似乎在于对象识别而不是获取属性,这可能是您正在测试的 Web 应用程序具有特殊的 javascript,它创建一个显示文本的浮动 HTML 元素。如果是这样,则可能是在特定事件发生(可能是鼠标悬停)之前不会创建此元素。这可能就是 QTP 无法识别该对象的原因,它还不存在。如果确实发生了这种情况,您应该首先在基本 HTML 元素上触发相关事件(使用 QTP 的 FireEvent 方法),然后尝试使用工具提示元素。

Native tooltips are actually the title property of an HTML element, so in order to get an element's title you can do Browser("a").Page("b").WebElement("c").Object.title.

However from what you describe it sounds like your problem is in object identification not in getting the property, it could be that the web application you're testing has special javascript that creates a floating HTML element that displays the text. If so it could be that this element isn't created until a specific event happens (probably a mouseover). This can be why QTP can't recognise the object, it doesn't yet exist. If this is really what's happening you should first fire the relevant event on the base HTML element (using QTP's FireEvent method) and then try to work with the tool tip element.

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