Thursday, November 10, 2011

How to use the FireEvent method when a click does not work

Overview: While using QTP’s click method on a search WebElement earlier today, I had an issue with a WebTable’s populate event not being triggered as it should have. If you ever experience a similar problem with your application (not performing an expected action after a certain event occurs), don’t give up – and be sure to try the FireEvent method. Description: The FireEvent method is designed to trigger events in an application. Syntax: The Syntax for the FireEvent is: yourObject.FireEvent EventName,[x-optional],[y-optional],[BUTTON-optional] Valid Events: The events available when using the FireEvents method are:
  • onchange
  • onclick
  • ondblclick
  • onblur
  • onfocus
  • onmousedown
  • onmouseup
  • onmouseover
  • onmouseout
  • onsubmit
  • onreset
  • onpropertychange
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"

What is DOM? and How to use DOM properties in QTP?

What is DOM?

The Document Object Model (DOM) is a cross-platform and language-independent convention for representing and interacting with objects in HTML, XHTML and XML documents. Aspects of the DOM (such as its "Elements") may be addressed and manipulated within the syntax of the programming language in use. The public interface of a DOM is specified in its application programming interface (API).

how the browser display's objects in the browser
  DOM
   |-> Window
       |-> Document
             |-> Anchor
             |-> Link
             |-> Form
                  |-> Text-box
                  |-> Text Area
                  |-> Radio Button
                  |-> Check Box
                  |-> Select
                  |-> Button


QTP will be able to access to Internet Explorer Document Object Model (DOM) through which we will be able to access the HTML tags directly. Access to the DOM is performed using the .Object notation.

below function explains how to iterate all the tags in an Internet Explorer page. The function then outputs the inner-text of the tags (the text contained between the tags) to the Test Results using the Reporter object.

' we are using On Error Resume Next option because all the page elements might not have inner-text. 
 On Error Resume Next 
 Set Doc = Browser("CNN Interactive").Page("CNN Interactive").Object 
 ' Loop through all the objects in the page. 
 For Each Element In Doc.all 
 TagName = Element.TagName ' Get the tag name. 
 InnerText = Element.innerText ' Get the inner text. 
 ' Write the information to the test results. 
 Reporter.ReportEvent 0, TagName, InnerText

QTP 11 Now Supports Google Chrome

Wow what a great news now QTP 11  Supports GOOGLE Chrome !!!!!!!!!!!!!!!!!


HP Patch QTPWEB_00088 features and limitations

HP just released a new patch QTPWEB_00088 that contains the following features and limitations:

QTP does not support recording steps in Google Chrome

Certain Google Chrome Javascript functionality, like web pages that use JSON objects, may cause unexpected behavior in QTP.
If you manually uninstalling the QTP agent extension from Tools>Extensions, you must manually reinstall it if you reinstall this patch.
Browser methods will not be supported

Also the following methods are not supported:

Browser.Home
Brpwser.Fulscreen
Browser.ClearCache
Browser.Objects
Running steps not supported:

Chrome: //* pages
Multiple tabs
Multiple browsers
Web pages that include frame sets
WebXML test objects
Web test objects located inside iFrame controls with a'blank' or 'about:blank 'SRC in property value
Developers Tools Pane but running against Google Chrome while the developers tools pane is open is supported
Web 2.0 test objects or Web Extensibility-based test objects
Web-based env, such as SAP Web, Siebel, Java, .NET Webforms etc..

Click here to Download QTPWEB_00088 Patch

Thanks to Joe for such valuable information http://www.joecolantonio.com/2011/11/02/qtp11-now-supports-google-chrome-patch-qtpweb_00088/