问题
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.
回答1:
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.
来源:https://stackoverflow.com/questions/8154277/qtp-how-do-we-capture-the-tool-tip-text-displayed-on-doing-mouseover-on-a-radi