-
OnMouseOver:
Browser(
"Registration | Demoqa").Page(
"Registration | Demoqa").Image(
"Tools-QA-213").
FireEvent MouseOver ????
The event is sent to the container of the ActiveX object and does not affect the ActiveX object itself. For example, simulating a click event does not actually perform the click.???
Source: http://www.joecolantonio.com/2011/06/07/qtp-how-to-use-the-fireevent-method-when-a-click-does-not-work/
Description:
The FireEvent method is designed to trigger events in an application.
Syntax: Valid Events:The Syntax for the FireEvent is:
yourObject.FireEvent EventName,[x-optional],[y-optional],[BUTTON-optional]
The events available when using the FireEvents method are:
- onchange
- onclick
- ondblclick
- onblur
- onfocus
- onmousedown
- onmouseup
- onmouseover
- onmouseout
- onsubmit
- onreset
- onpropertychange
Ex:
The click method below was not working:
Set mainPath = browser(“CB”).Page(“CB”)
mainPath.WebElement(“Search”).Click
…but using the FireEvent did work:
mainPath.WebElement(“Search”).FireEvent “ondblclick”
-
Source: http://www.learnqtp.com/capture-tool-tips-using-qtp-uft/
Tool Tip:
Attributes in the object spy - properties window will help you to find the tool tip text.
4 Ways to Capture Tool Tips using QTP (UFT)
Beginners to QTP often get confused on how to capture tool tips from various UI elements. Since tool tips appear on mouse hover event, people often resort to using mouseover events, which in my opinion doesn’t give consistent results. In this article, we will talk about the generic process using which we can capture tool tips from various applications.
What is a Tool Tip?
Tool tip is a GUI element which is used to provide hints or brief details about an item when you hover a mouse on it. This item can be a link, image, edit box or any GUI element where application demands extra helpful hints.
Here is an illustration. A tool tip – Visit the main page – comes up when we hover our mouse on the logo of Wikipedia.
Tool tips can be seen in all types of apps, whether web based or desktop based applications.
General Process of Capturing a Tool Tip
- Hover your mouse to check whether the UI element has a tool tip associated with it.
- If it has a tool tip associated, make use of QTP’s object spy tool and check the property that contains the tool tip value.
- Most of the times, you will find that tool tip is present in title property.
- Use GetRoProperty to fetch the tool tip value.
Capture tool tip from a link
We will make use of
jsfiddle to show examples of tool tip usage.
As can be seen in the screenshot above, the title for link is defined as Go to home page. If you hover over the link – LearnQTP – you will see a tool tip titled “Go to home page”.
Let us use the process described above to capture this tool tip. Here is how the object spy looks for the link shown above.
The corresponding code to fetch this tool tip would be:
msgbox Browser("Edit fiddle - JSFiddle").Page("Edit fiddle - JSFiddle").Frame("result").Link("Learn QTP").GetRoProperty("title")
You can play with various values
here.
Capture tool tip from an image
In this case as well, the tool tip appears in the title tag.
The corresponding code to fetch this tool tip would be:
msgbox Browser("Google").Page("Google").WebElement("India").GetRoProperty("title")
Capture Tool Tip Using XPath
The two cases we discussed above were simple for the fact that that ‘Tool Tip’ was directly available using Object Spy. There will be cases where the tool tip is not directly attached with the object under consideration. In such cases, we can take help of XPath.
HP introduced object identification capabilities using XPath in QTP 11 which has continued through UFT 12. To demonstrate tool tip capturing with XPath, we will use
this website. The tool tip associated with the first name edit box is
Your first name is a optional
If you Object Spy on this edit box, you won’t find the tool tip mentioned in any of the properties. Hence in this case, we will locate the property using XPath and the
innerhtml property
. You may ask, how should I write XPath expression? If you want a detailed tutorial on it check this article on
XPath with QTP , if you are looking for an easier way read-on.
- Open this link in Google Chrome browser.
- Right click on the page and click on ‘Inspect Element’
- Use the little magnifying glass on the left and inspect ‘First Name’ edit box. Locate the tool tip in the console below.
- Highlight the row > Right Click > Copy XPath.
XPath associated with the First Name tool tip class is //*[@id=’tp1′]
This piece of code will give you the tool tip associated with First Name edit box using XPath.
msgbox Browser("ARIA Example: Tooltip").Page("ARIA Example: Tooltip").WebElement("xpath:=//*[@id='tp1']").GetROProperty("innerhtml")
Capture Tool Tip Using CSS
Along with XPath, HP also introduced Object identification using CSS in QTP 11. The process for capturing CSS path for this element would remain the same. In this case, the CSS associated with First Name tool tip is #tp1
This piece of code will give you the tool tip associated with First Name edit box using CSS.
msgbox Browser("ARIA Example: Tooltip").Page("ARIA Example: Tooltip").WebElement("css:=#tp1").GetROProperty("innerhtml")
I hope this article will help you identify tool tips in your application. If you have used some other ways, please share in the comments section below.