QTP:我们如何捕获在单选按钮上进行鼠标悬停时显示的工具提示文本? [英] QTP : How do we capture the tool tip text displayed on doing mouseover on a radiobutton?

查看:80
本文介绍了QTP:我们如何捕获在单选按钮上进行鼠标悬停时显示的工具提示文本?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

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

但我收到以下错误消息

无法识别(WebElement 类的)对象[WebElement].请验证此对象的属性是否与您的应用程序中当前显示的对象相匹配".

如果我通过将对象添加到对象存储库来运行相同的代码,我可以使用 GetROProperty

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

除了 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?

请提出建议.

我的完整代码如下所示.我也按照建议尝试了object.tile",但仍然是同样的问题.

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

请推荐

谢谢.

推荐答案

Native tooltips 实际上是 HTML 元素的 title 属性,因此为了获得元素的标题,您可以执行 Browser("a").Page("b").WebElement("c").Object.title.

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.

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

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.

这篇关于QTP:我们如何捕获在单选按钮上进行鼠标悬停时显示的工具提示文本?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆