17.7.14

Configuring Eclipse and Selenium

There is a lot of stuff that you need to configure when you are working with selenium [depending on your needs] but the simplest would be to just have eclipse and selenium - that is all you need, everything else is just an add-on, for specific task\extension that you want to have.

    You would need to have the following bare minimum.
        1. Selenium jars [most populare being the java specific bindings]
        2. Eclipse
        3. Java Development Kit [JDK] - Ensure to point everything to JDK and not the JRE.
   
    Steps to configure selenium and eclipse -
       
  1. Configure Java by installing the latest version of the JDK [default setup - no customizations needed] and then, add the following Java Environment variables
            Path -
                ;C:\Program Files\Java\jdk1.7.0_10\bin;
               
            JAVA_HOME -
                C:\Program Files\Java\jdk1.7.0_10

            JDK_HOME -
                C:\Program Files\Java\jdk1.7.0_10

CLASSPATH (This is not needed anymore) -
               C:\Program Files\Java\jdk1.7.0_10\lib;

             If you get an output like below for java, then java is correctly configured.

 
         2. Download eclipse [any version and variant would do]
            - There is no installation needed to run eclipse, just put the extracted eclipse folder in the directory 'C:\ToolDirectory' and you are ready to run
       
        3. Download the selenium java bindings from the selenium HQ
            - Extract the zip and put that in the directory 'C:\ToolDirectory'. Lets follow a convention of naming the selenium folder like 'selenium-2.4.2'. Now place all the jar files under the selenium folder [there are usually 2 jar files that are extracted out in a seperate folder].
       
        4. Fire up eclipse
            - Create a new java project, like 'se-auto'
            - Under the src folder create folder structure like src\main\java and src\test\java
            - Associate all external selenium jars with the project
       
Thats all, you are all set!


Some DONTs -
  • Dont create a PATH var, but only Path - otherwise have seen issues with maven config
  • JAVA_HOME should not end with bin
  •  JAVA_HOME cannot have "\" or ";" in the end.
  • ";" should not be there at all
  • Ensure that the bit-architecture of the JDK and Eclipse is same - either both are 32-bit or both 64-bit - but not different. The OS bit-version can be anything, but now a days mostly everything is 64-bit, so ensure that you have the 64-bit trio for OS, JDK and Eclipse

Common Troubleshooting -
  • If you are still having issues, even after following the above steps correctly, first restart the machine before doing any more troubleshooting
  • View all Env Parameters - 
    • To view and dump all the Env params to a file use the following command on CMD:
      • set >> AllEnvParam.txt
    • To view all the Java Properties use: java -XshowSettings:properties -version
  • If you have installed the Java Add-in for QTP, then this can cause issues, and not let eclipse and other java dependent programs start. You may get an error that the JVM is incompatible or that the older version of java is not supported. If you don't need the Java Add-in, uninstall it, or remove the Env Variables that are being used.
  • Some of the other Env Variables like those below cause conflicts and can be delete
    • _JAVA_OPTIONS
    • IBM_JAVA_OPTIONS
    • JAVA_TOOL_OPTIONS
    • _classload_hook
  • If you have Oracle SQL Developer installed, then the Oracle JDK may be added to the JAVA_HOME Env param. Delete the value of the Oracle JDK from JAVA_HOME and ensure that only Java JDK is mentioned there, and nothing else.
  • If you have IntelliJ IDEA also installed, then point the 'IDEA_JDK' also to the JAVA_HOME
  • Error - 'Failed to load JNI shared library' - This occurs when the JDK and Eclipse have different bit-architectures. This can also be resolved by adding JAVA_HOME\bin to the start of the Path Variable. A very common resolution suggested for this is to specify the location of the javaw.exe in the eclipse.ini file, but it is not needed if we use the above approach.

Using different Firefox Profiles with Selenium WebDriver

By default, there is just one firefox profile [called 'default'] for a given user which is used everytime one opens firefox, but using this default profile may not be the best option when running webdriver scripts.
Hence, it is better to create a new profile specifically to be used just by the webdriver.
Although, there are more powerful and effective ways to manage firefox profiles and preferences with WebDriver, but the one below is simple and effective too, and is enough for most cases. The only hitch with this method is that you will have to manually create the same firefox profile on every computer that you want to run your tests

Steps to create a new firefox profile -

•    Close all open sessions of the firefox browser
•    Type the following command on the Run window - "firefox -ProfileManager"
•    Here you will see just one profile initially, the 'default' one
•    Create a new profile and name it as 'webdriver'
•    Launch this profile and perform any configurations like disabling/enabling certain add-ons, maximize, etc
•    Close the firefox browser.
•    Now, whenever this profile will be opened, it will open with the configurations that you made.



Steps to use this new profile with webdriver -

    ProfilesIni profilesIni = new ProfilesIni();

    FirefoxProfile profile = profilesIni.getProfile("webdriverprofile");

    WebDriver foxdriver = new FirefoxDriver(profile);

We might also encounter issues with security certificates on firefox, so to overcome those, the following can be used

If the certificate is valid but self-signed
    profile.setAssumeUntrustedCertificateIssuer(true); //this is the default setting

If the certificate is invalid
    profile.setAssumeUntrustedCertificateIssuer(false);


Using this code above, the webdriver will open firefox with the profile specified, and not the default one.

3.7.14

Transformation from QTP to Selenium

Proof of how bored I am right now..... :-)


Transformation from QTP to Selenium

31.5.14

How to work with QC OTA - Example 3 - Function to Run a Query on QC Database

'------------------------------------
' Function Name:         funcRunQueryOnOC
' Description:               This function will run a query on the QC database and then return the recordset containing the results
' Input Parameters:     sQCQuery - The query to be run on the QC database
' Output Parameters:  The QC RecordSet Object
' Author:                      Ashish Jaiswal
'------------------------------------

Function funcRunQueryOnOC(sQCQuery)

    'Getting the QC Connection Object. Refer earlier post about the implementation of this function.
    Set oALMConnObj = funcGetALMConnectionObj (sQCServer, sQCUsername, sQCPassword, sQCDomain, sQCProject)

    'Getting the Command object to run the query
    Set oQCCommand = oALMConnObj.Command

    oQCCommand.CommandText = sQCQuery
    'Sample query: "Select * from Bug where BG_BUG_ID = 9295"

    Set oQCRecordSet = oQCCommand.Execute

    'Now returning the recordset
    Set funcRunQueryOnOC = oQCRecordSet

End Function 
'------------------------------------

How to work with QC OTA - Example 2 - Get a List of All Defects in QC

Code to get a list of all the details for all the defects in QC Defects Module


''Complete path of the file where the info from QC needs to be written
sQCLogFilePath = "C:\Automation\Defects_List.csv"

Set oFSO = CreateObject("Scripting.FileSystemObject")
Set oFile = oFSO.CreateTextFile(sQCLogFilePath)

''Getting the QC Connection Object. Refer earlier post about the implementation of this function
Set oALMConnObj = funcGetALMConnectionObj (sQCServer, sQCUsername, sQCPassword, sQCDomain, sQCProject)

''Getting the Bug Factory object
Set oBugFactory = oALMConnObj.BugFactory

Set oBugList = oBugFactory.NewList("")

oFile.WriteLine("Defect ID" & "," & "Summary")

For Each oBug In oBugList

oFile.WriteLine(oBug.ID & "," & oBug.Summary)
''We can add other fields as: Bug.Status, Bug.Priority, Bug.AssignedTo

Next

Set oFile = Nothing
Set oFSO = Nothing
Set oBugFactory = Nothing
Set oALMConnObj = Nothing

How to work with QC OTA - Example 1 - Get Defect ID and the size of Attachments in each defect

More often than not, we get weird requests, like getting a list of all the defects in QC and the size of attachments for each of them, but thankfully we have QC OTA to help us ease the pain. Use the below code to get a file with Defect ID and the size of all the attachments for them.


''Complete path of the file where the info from QC needs to be written
sQCLogFilePath = "C:\Automation\Attachments_List.csv"

Set oFSO = CreateObject("Scripting.FileSystemObject")
Set oFile = oFSO.CreateTextFile(sQCLogFilePath)

''Getting the QC Connection Object. Refer earlier post about the implementation of this function
Set oALMConnObj = funcGetALMConnectionObj (sQCServer, sQCUsername, sQCPassword, sQCDomain, sQCProject)

''Getting the Bug Factory object
Set oBugFactory = oALMConnObj.BugFactory

''Defining the filters for the Defects
Set oBugFilter = oBugFactory.Filter
oBugFilter.Filter("BG_STATUS") = "Closed"
oBugFilter.Filter("BG_ATTACHMENT") = "Y"
oBugFilter.Filter("BG_DETECTED_BY") = "ASHISH.JAISWAL"

Set oBugList = oBugFilter.NewList

oFile.WriteLine("Defect ID" & "," & "Total Attachment Size")

For Each oBug In oBugList

        Set oBugAttachments = oBug.Attachments
        Set oBugAttachmentList = oBugAttachments.NewList("")

        iTotalAttachmentSize = 0
        For Each oBugAttachment In oBugAttachmentList
            iTotalAttachmentSize = iTotalAttachmentSize + oBugAttachment.FileSize
        Next

        oFile.WriteLine(oBug.ID & "," & iTotalAttachmentSize)

        Set oBugAttachmentList = Nothing
        Set oBugAttachments = Nothing

Next

Set oFile = Nothing
Set oFSO = Nothing
Set oBugFilter = Nothing
Set oBugFactory = Nothing
Set oALMConnObj = Nothing

19.5.14

Convert QTP Results XML to HTML

QTP generate it's results in an XML format. We can use the inbuilt result convertor to convert these into any format we want, but for that we need to have the RunResultsViewer installed on the system. But we can also convert these results into an HTML file manually. In order to convert this XML to any other format we need to use the XSL style sheet to define the conversion.
XSL is a Stylesheet language which can be used to transform an XML according to the specification. The output could be a HTML file, a text file, a XML file etc...To do this transformation at run-time we need to load the XML, and then the XSL into that, and save the output.

QTP comes with 3 different XSL files which would be located in the following folder - "C:\Program Files (x86)\HP\QuickTest Professional\dat\"

    PDetails.xsl - for getting the detailed results in HTML format
    PShort.xsl - for getting the short results in HTML format
    PSelection.xsl - for getting the selective results in HTML format

The PSelection.xsl file requires input arguments for the XSL and the other 2 can be directly loaded into the XML.

We can either refer these XSL files from the default directory [dat] or copy them to any folder we like, and then reference from there. Also, in order for the results to be displayed correctly the PResults.css [also located in the dat folder] file should be present in the same folder as the output HTML file. Hence, in order to avoid creating all the new result HTML files in the dat folder itself, its better to copy all the required files to a different directory and then work off of that one.

Below is the function that would do this conversion.


'''--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
'' Function Name:         funcConvertResultsXMLtoHTML
'' Description:         This function will convert the QTP Results.xml into HTML format, with Detailed or Short versions.
''                         This can be called from within QTP, or an external VbScript
'' Input Parameters:     sInputResultsXML - The path of the QTP Results.xml
''                         sXSLType - The XSL type, based on which the results will be converted to either Detailed or Short version
''                         sOutputHTMLPath - The complete path where the HTML result file needs to be created
'' Output Parameters:     None
'' Author:                 Ashish Jaiswal
'''--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Function funcConvertResultsXMLtoHTML (sInputResultsXML, sXSLType, sOutputHTMLPath)

    ''Creating an instance for the DOMDocument Class of the MS XML Parser [MSXML.dll]
    Set oXMLDoc = CreateObject("MSXML.DOMDocument")
    Set oXSLDoc = CreateObject("MSXML.DOMDocument")

    ''Since a file is loaded asynchronously by default by the parser, we set it to false
    ''By setting the document's Async property to False, the parser will not return control to your code until the document is completely loaded and ready for manipulation. If you leave it set to True, you will need to either examine the ReadyState property before accessing the document or use the DOMDocument's events to have your code notified when the document is ready. Using the default value may cause issues during reading and writing to file, hence, its best to keep things simple, and let it be False.
    oXMLDoc.ASync = False
    oXSLDoc.ASync = False

    ''Opening the document via the Load method, by specifying the path of the input XML and XSL
    ''The XML parser can load XMLs from the local disk, over the network using the UNC path, or via a URL
    oXSLDoc.Load sXSLType
    oXMLDoc.Load sInputResultsXML

    ''Processing the entire XML (it processes all the nodes and the children) using the specified XSL Style Sheet, and then returning the transformation
    sTransformedXML = oXMLDoc.transformNode(oXSLDoc.documentElement)

    ''Creating a new file to hold the transformed XML data - the output HTML file, and enabling overwriting the file with True
    Set oFSO = CreateObject("Scripting.FileSystemObject")
    Set oOutputHTML = oFSO.CreateTextFile(sOutputHTMLPath,True)

    ''Writing the transformed text to the HTML file
    oOutputHTML.Write sTransformedXML

    ''Saving the file finally
    oOutputHTML.Close

    ''Destroying the objects
    Set oOutputHTML = Nothing
    Set oFSO = Nothing
    Set oXMLDoc = Nothing
    Set oXSLDoc = Nothing

End Function
'''--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

Now to use the function...

''Path of the Results file which needs to be converted
sResultsXMLPath = "C:\auto\Results.xml"

''Path of the XSL for detailed version
sDetailedXSLPath = "C:\auto\PDetails.xsl"

''Path of the XSL for short version
sShortXSLPath = "C:\auto\PDetails.xsl"

Call funcConvertResultsXMLtoHTML (sResultsXMLPath, sDetailedXSLPath, "C:\auto\Results_Detailed.html")
Call funcConvertResultsXMLtoHTML (sResultsXMLPath, sShortXSLPath, "C:\auto\Results_Short.html")
 
 
 

5.4.14

Invoke a Web Service via VbScript using the WinHTTPRequest Object


As part of our functional tests, there might be a need to invoke a web service directly. We can do that by using the Web Service Add-in of the QTP, or by a simple VbScript code [which would be much faster] as shown below.

Sample Code:

'''----------------------------------------------------------------------------------------------------------------------
'The URL of the site or of a webservice which we need to access
sURL = "http://intranetportal.anycompany.com/"


'Create the WinHTTPRequest COM Object
Set oWinHttpReq = CreateObject("WinHttp.WinHttpRequest.5.1")

'Create an HTTP request
oWinHttpReq.Open "POST", sURL, False

'Send the HTTP request
oWinHttpReq.Send()

'Wait 4 sec for the Response to come
oWinHttpReq.WaitForResponse(4)

'Retrieve the Status
MsgBox oWinHttpReq.StatusText

'Retrieve the response text
MsgBox oWinHttpReq.ResponseText

'''----------------------------------------------------------------------------------------------------------------------
''These can be added later if needed
''sContentType = "text/XML"
''oWinHttpReq.setRequestHeader "Content-Type", sContentType
''oWinHttpReq.setRequestHeader "Accept", sContentType
''oWinHttpReq.setRequestHeader "Connection", "keep-alive"
''oWinHttpReq.SetTimeouts 5,5,5,5
''oWinHttpReq.Option WinHttpRequestOption_URL
'''----------------------------------------------------------------------------------------------------------------------




Notes:
  • HTTP Verb: The HTTP verb (or HTTP method) is an instruction sent in a request message that notifies an HTTP server of the action to perform on the specified resource. For example, "GET" specifies that a resource is being retrieved from the server. Common verbs include "GET", "POST", and "HEAD". For more information and a complete list of standard HTTP verbs, see the HTTP/1.1 specification.
  • The Open method does not establish a connection to the resource as the name might imply. Rather, it initializes the internal data structures that maintain information about the session, connection, and request. The HTTP verb "GET" obtains data from the URL. False implies that the transaction occurs synchronously
  • The Send method assembles the request headers and sends the request. When called in synchronous mode, the Send method also waits for a response before allowing the application to continue. Sometimes the operations may get timed out but its not because of some error in the code but because it may be blocked by the company firewall. To overcome this, try using the URL of an Internal Site

Connect to ALM-QC via VbS or QTP


You can use the following code to connect to ALM\QC via pure VbScript, without using QTP, even though this code would work from QTP as well.

Prerequisite:
  • ALM\QC should be installed

Code -

'''----------------------------------------------------------------------------------------------------------------------
'' Function Name:            funcGetALMConnectionObj
'' Description:                   This will connect to the ALM\QC server via either pure VbS or QTP
'' Input Parameters:        sQCServer
''                                         sQCUsername
''                                         sQCPassword
''                                         sQCDomain
''                                         sQCProject
'' Output Parameters:     oALMConnObj [The ALM Connection Object]
'' Author:                          Ashish Jaiswal
'''----------------------------------------------------------------------------------------------------------------------
Function funcGetALMConnectionObj (sQCServer, sQCUsername, sQCPassword, sQCDomain, sQCProject)

    ''Defining the Parent QC OTA Object
    Set oALMConnObj = CreateObject("TDAPIOLE80.TDConnection")

    ''Initiating the connection to the QC Server
    oALMConnObj.InitConnectionEx sQCServer

    ''Logging in
    oALMConnObj.Login sQCUsername, sQCPassword

    ''Connecting to the required project and domain
    oALMConnObj.Connect sQCDomain, sQCProject

    ''Returning the object
    Set funcGetALMConnectionObj = oALMConnObj

End Function
'''----------------------------------------------------------------------------------------------------------------------

Usage:

''Defining the connection parameters for QC
sQCServer = "http://ealm11.anyorg.net/qcbin/"
sQCUsername = "username"
sQCPassword = "password"
sQCDomain = "domain"
sQCProject = "projectname"

Set oALMConnObj = funcGetALMConnectionObj (sQCServer, sQCUsername, sQCPassword, sQCDomain, sQCProject)

''Proceeding ahead only if connected
If oALMConnObj.Connected Then

    MsgBox "Connected to QC!"
    MsgBox oALMConnObj.ProjectName

Else

    MsgBox "Not connected to QC"

End If
'''----------------------------------------------------------------------------------------------------------------------

Common troubleshooting measures -

  • Register the OTAClient.dl
    • For this put the OTAClient.dll in the "C:\Windows\System32" drive, if its not already there
    • Run the following command to [re]register the dll from the Run window
                      RegSvr32 "C:\Windows\System32\OTAClient.dll"

  • If you are getting an error something like 'ActiveX can't create object - TDConnection' then try running the connection code by putting in a .vbs file, from the Run window as follows, via the WScript.exe -
           C:\Windows\SysWOW64\wscript.exe "C:\Automation\QC-Connection.vbs"

28.9.13

Working with HTML DOM and QTP

The other day a junior team member of mine was having hard time working with HTML DOM and QTP, he was confused between a lot of terms like tags, attributes, values, properties, DOM elements, GetROProperty, GetTOProperty....the list was endless, and as usual, he was already late to meet the deadline. So, instead of asking him to google all the 'gyaan' on this topic, I gave him a shot of red bull, as follows.....

•    The Document Object Model (DOM) is a platform and language-neutral interface that allows programs and scripts to dynamically access and update the content, structure, and style of a HTML document. The HTML DOM defines the objects and properties of all HTML elements, and the methods (interface) to access them. JavaScript uses DOM to add interactivity to HTML pages. The DOM is an API for HTML and XML documents. It provides a structural representation of the document, enabling you to modify its content and visual presentation.

[ The most important thing to realize is - what we refer to as "Property" of an object in QTP, is actually the "Attribute" in HTML terms, and the Value of the Property is actually the value defined for that Attribute. ]
 You can modify the appearance and behavior of an HTML element by altering a DOM object's properties and calling its methods.
When you use the QTP's "Object Property" for a Web object, you actually get a reference to the DOM object. You get access to the native methods and properties of that web object.
This means that any operation that you can perform on a DOM object, you can also perform by running a <WebTestObject>.Object statement on the Web object.
For example, you can use the links property of the Internet Explorer document object to retrieve a link collection.
Example: Activate an Edit Box's Native Focus Method

    Set MyWebEdit = Browser("Mercury Tours").Page("Mercury Tours").WebEdit("username").Object
    MyWebEdit.focus

All the values of the attributes can be accessed by using the following syntax in DOM (as shown below):
    object.attribute
These attribute values can also be accessed via GetROProperty method in QTP.
Both the sets of code (the one with the DOM and the other with QTP methods) will return the same values, the only difference being that if a attribute does not exist, then the DOM returns an Error whereas the QTP GetROProperty method returns 0.

•    Common Methods used in DOM:

        •    Supported by QTP by defualt
                •    getElementById
                •    getElementsByName
                •    getElementsByTagName
           
When we use methods like the GetROProperty to read property values of the objects, QTP actually returns the values of these attributes that are defined for that object. Hence, if we use GetROProperty("href") it will return the value of the href attribute.
If we want to do this via DOM then we can get the value of href property by using the below code:
sHref = oDOM.Document.getElementById("OpenAcct").href

•    DOM vs DP:   
    Code written in DOM will be substantially faster than the code written in DP (to perform the same operation), because there will be no overhead of Object identification with DOM. QTP UnP Pg 202.
           
    Methods like GetROProperty, GetTOProperty, etc will not be supported by DOM elements directly because they are QTP specific methods. However, these methods will be supported by DP because DP is nothing but the same QTP code.
                       
•    Tools: Even though QTP has a good built in Object-Spy, its nowhere close to what Firebug add-on for FireFox can do, and is a must in anyone' arsenal of tools.


•    WebTablesNow a days modern websites dont use the 'table' tags for building their pages and displaying content, because of the following reasons

  • More number of code needs to be written and maintained overtime as compared to the use of div tags
  • It makes the page structure rigid
  • It tries to mix the content and the style, which is not a good practice
  • Its difficult to display the data correctly on mobile devices with table tags


If there are multiple nested table tags in the html code for displaying data in tabular format, then that's a poorly written code.
As opposed to this, DIV tags provide easy maintenance, faster loading and search engine friendly features, as described here

Hence, now a days only DIV tags are used to structure data in tabular format. This also means that 'grids' would be used to display data in tabular format. Grids and Tables are 2 different things in HTML world.



Having said all this, it does not mean he can get away with not having to understand HTML, DOM, and related concepts, as I have ensured that this goes in his appraisal goal sheet, and I would suggest you do the same, if not done already.

Happy learning!!!

31.7.13

Is a formal Certification in Testing still Relevant?


The real answer to this is - it depends! on the context, on the need, on necessity, on motivation, on relevance, and even on geography...
Is it absolutely necessary - definitely not! Should you go for it - may be. Why? - read the first line.

OK, now the real reasons.
What a formal Certification (like ISTQB) does is a lay a foundation about the basic process of Software Testing, that anyone who works in this field is expected to know - you cannot build an Empire state building with only 6 inches of slab as foundation.
But I feel that the course-ware (syllabus) is mostly irrelevant in today's real world scenario, though some of it can be pretty useful even in the advanced stages of your careers. It is like the basics of engineering that we all studied but rarely used, but it was still important at that point of our lives.
So, the point is if you are just starting your career in testing - most of the young people in India and some Asian countries fall in this category  - it might be worthwhile to go for it. Because most testers start their careers in testing without any formal training in the different aspects of testing, and they keep struggling until they develop that knowledge and understanding. So all this certification can do is speed-up that learning a bit, by pointing you in the right direction.

But for people who have credible experience it may not be worth spending a weekend that you could have spent on taking your wife shopping! For people in mature markets like US and EU, this certification has already lost all relevance; and for those who want to 'statistically' refuse, here is a good article that can help you do just that - http://chrismcmahonsblog.blogspot.in/2010/10/ignoring-certification-with-numbers.html

A weekend is all it takes to clear these certifications - but its no cake-walk either as the failure rate is quite high, though the material is quite abundantly (and freely) available online.

One exam tip for those who want to take the plunge - don't sweat too much over the 'Standards' even if you get the itch to do so, because not much gets asked about those anyways!

1.7.13

When QTP is unable to Identify Web Objects

Often we are faced with an issue when QTP cannot identify the objects in a web page.
So, listed below are some of the things we should try (in no particular order). This is not an exhaustive list (yet), but this could give some pointers or options that you may not have tried.

Bear in mind that Uninstall & Re-install should always be the last option - no matter how tempting it is ;-)

•    Check the compatibility of QTP with OS and IE.

•    IE Browser > Tools > Internet Options > Disable the "Enable Tabbed Browsing" checkbox.  
    This worked for me on Windows 7 with IE 8 and QTP 11 - Jun2012

•    IE Browser > Tools > Internet Options > Disable the "Enable Protected Mode" checkbox. If Protected Mode is required to be set as ON, then a QTP Patch QTPWEB_00073 is needed.


•     Sometimes QTP identifies objects on the main browser page but not on the child page. This may happen when web pages have Web 2.0 elements embedded in them. These Web 2.0 apps are not based on new technology but instead on a set of cumulative toolkits or frameworks, like AJAX, Dojo, Yahoo User Interface (YUI) and GWT. In such cases, we have to enable/install Web 2.0 toolkit add-ins in QTP. Refer the following links in such a case:


•    UAC (User Account Control) has to be disabled on Vista and for Windows7 has to be set to "Never Notify"

•    If QTP's BHOManager Addon is disabled in IE, even this can cause issues, and has to be Enabled.
    To enable it go to IE > Tools > Addons > BHOManager Class - Enable

•    IE Browser > Tools > Internet Options > Advanced > Browsing > Enable Third Party Browser Extensions

•    For FireFox, ensure that QTP Plugin is available in the Extensions section of the Addons in Fox



•    Ensure that the Browser is running in 32-bit mode, even if the machine is 64-bit because QTP is a 32-bit app. To ensure this during run-time, pass the complete path for the browser (the one with (x86)) via SystemUtil.Run

List of COM Objects

We often work with a lot of COM objects, and it may cause errors if we define them incorrectly, so, here is a list of commonly used COM objects.

Set oQTPApp =                 CreateObject ("QuickTest.Application")
Set oWSHNetwork =          CreateObject ("WScript.Network")
Set oWSHShell =             CreateObject ("WScript.Shell")
Set oShell =                     CreateObject ("Shell.Application")
Set oFSO =                         CreateObject ("Scripting.FileSystemObject")
Set oWMI =                     GetObject ("WinMgmts:")
Set oWMIService =         GetObject ("WinMgmts:{ImpersonationLevel=Impersonate}!\\.\Root\Cimv2")    ' ''The "." can be replaced by compturename

Set oADOConn =             CreateObject ("ADODB.Connection")
Set oADORecSet =             CreateObject ("ADODB.Recordset")
Set oDeviceReplay =        CreateObject ("Mercury.DeviceReplay")
Set oIE =                             CreateObject ("InternetExplorer.Application")
Set oDic =                         CreateObject ("Scripting.Dictionary")
Set oWinHTTP =             CreateObject ("WinHTTP.WinHTTPRequest.5.1")
Set oXmlDoc =                 CreateObject ("Microsoft.XmlDom")
Set oXml2Doc =              CreateObject ("MSXml2.DOMDocument.5.0")
Set oSoapClient =              CreateObject ("MSSoap.SoapClient")
Set oCal =                          CreateObject ("MSCAL.Calendar")
Set oQuattro =                  CreateObject ("QuattroPro.PerfectScript")
Set oWPerfect =              CreateObject ("WordPerfect.PerfectScript")
Set oRandom =                  CreateObject ("System.Random")
Set oArrList =                  CreateObject ("System.Collections.ArrayList")
Set oSortList =                  CreateObject ("System.Collections.SortedList")
Set oiTunes =                  CreateObject ("iTunes.Application")
Set oWMPlayer =              CreateObject ("WMPlayer.OCX")
Set oWM7Player =          CreateObject ("WMPlayer.OCX.7")
Set oRealPlayer =              CreateObject ("rmocx.RealPlayer G2 Control.1")
Set oFSDialog =                  CreateObject ("SAFRCFileDlg.FileSave")
Set oFODialog =              CreateObject ("SAFRCFileDlg.FileOpen")
Set oDialog =                  CreateObject ("UserAccounts.CommonDialog")
Set oWOL =                      CreateObject ("UltraWOL.ctlUltraWOL")
Set oSearcher =              CreateObject ("Microsoft.Update.Searcher")
Set oEmail =                      CreateObject ("CDO.Message")
Set oInet =                      CreateObject ("InetCtls.Inet.1")
Set oExcel =                      CreateObject ("Excel.Application")
Set oOutlook =                  CreateObject ("Outlook.Application")
Set oPpt =                          CreateObject ("PowerPoint.Application")
Set oWord =                      CreateObject ("Word.Application")
Set oHTML =                     CreateObject ("HTMLFile")