Showing posts with label QTP. Show all posts
Showing posts with label QTP. Show all posts

13.4.17

Troubleshooting hacks, Jugaad


1.              Guice Provision Error -
Cause - Happens when Surefire plugin is initiated on Maven 3.0.5 (which is too old now). This usually happens on Jenkins/TC when the default settings for Maven are used.
Resolution - Use latest version of Maven and specify the same in Jenkins' Maven Settings too

2.              SurefireBooterException -          
To resolve, add this config in the POM, to set useSystemClassloader to false:
<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-surefire-plugin</artifactId>
    <configuration>
        <useSystemClassLoader>false</useSystemClassLoader>
    </configuration>
</plugin>

3.              Run Maven commands without changing dir –
We don’t need to ‘cd’ to the directory containing the pom every time we want to run a mvn command, we can fire the mvn command from anywhere as long as we give the path to the pom like below:
Syntax: mvn –f <fullpath-to-pom> <goals> -D<params>
Sample: mvn –f C:/Automation/keyword/pom.xml test –Dthread1=Test1
It would be good to not have any spaces in the path so as to avoid escape char.
Use / instead of \  in the path.

4.              Invoke CMD via VbScript –
If you want to invoke the CMD utility automatically with certain parameters then use the below snippet:
Set oShell = CreateObject(“WScript.Shell”)
cmndToRun = “mvn –f C:/Automation/keyword/pom.xml test –Dthread1=Test1”
oShell.Run “cmd.exe /k “ & cmndToRun
To keep the CMD window open use /k after cmd.exe or use /c to close it.

5.              StackOverflowError –
Happens due to infinite recursion. For example when a method invokes itself during its execution or where one class object is instantiated under another class recursively. We will not get any compile-time Errors, but at runtime we will get this Error.

6.               Maven Compilation Error - package <name> does not exist
Resolution - Sometimes old or un-used packages are not found after updating versions of some libraries, which causes compilation Errors. Fastest solution is to delete these unwanted packages from Java files.

7.              Log4J package is not getting imported in the classes, hence, not able to initiate logging.
Steps to troubleshoot - A combination of these resolved this, after multiple iterations
·       Tried mvn dependency:resolve - It got successfully downloaded when resolving dependencies via mvn.
·       Delete local repo and re-download all dependencies from scratch - Even after deleting the old local repo, and rebuilding the same from scratch, it does not work
·       'Cleaned' the eclipse project - it resolved all Errors, but still Log4J is not getting imported.
·       Delete '.lastUpdated'  files from local repo
·       For Windows cd (change directory) to <user-directory>\.m2\repository and execute this command:
for /r %i in (*.lastUpdated) do del %i
·       Now update dependencies again.
·       You could also get Errors like: [Could not find artifact org.apache.logging.log4j:log4j:jar:2.6.1 in central (https://repo.maven.apache.org/maven2) -> [Help 1]]
·       Run mvn eclipse:eclipse - This could cause the following Error, visible only on eclipse, not in maven: [The project was not built due to "Resource already exists on disk: '/bddproject/target/classes/log4j.properties'.". Fix the problem, then try refreshing this project and building it since it may be inconsistent]. To resolve it, run mvn clean, as it will delete the target folder, where this Error was. Then go to eclipse and do Project > Clean. Now, all Errors should be resolved.

8.              Get 'failed to load jvm' Error when running eclipse
            Try restarting the machine, it gets resolved sometimes

9.              Even though the default story steps[in myStory] have been implemented, while running the MyStories class, they still come up as @Pending in the results.
Cause - The Pending annotation was already imported by default in the default MySteps class, which was marking all the steps as pending.
Resolution - Delete that import statement for Pending, and re run the test, it worked and all steps were Green/Run/Passed
Also, if now I add a Pending annotation but do not use it, it still runs the remaining steps, as it should run.
 
10.          Getting junk lines being reported in the console with the freemarker log -
Like - "Jul 05, 2016 1:17:56 AM freemarker.log._JDK14LoggerFactory$JDK14Logger info"
If Log4J works, then this is not needed

11.          Run via mvn is Erroring out -
mvn clean install - this command Errors out
Error - [Error] Failed to execute goal org.jbehave:jbehave-maven-plugin:4.0.5:run-stories-as-embeddables (embeddable-stories) on project bddproject: Execution embeddable-stories of goal org.jbehave:jbehave-maven-plugin:4.0.5:run-stories-as-embeddables failed: A required class was missing while executing org.jbehave:jbehave-maven-plugin:4.0.5:run-stories-as-embeddables: org/apache/log4j/Priority

12.          The simple-archetype comes with the default jbehave report template, which needs to be fixed

13.          Even though the M2E plugin is downloaded and installed, it does not show up in eclipse - there is nothing for maven

14.          Getting the following Error while running dependency:resolve command
Error - Failed to collect dependencies at org.jbehave:jbehave-core:jar:4.0.5 -> com.thoughtworks.xstream:xstream:jar:1.4.7:
Cause - Looks like the command to download the dependencies was getting timed out, as it worked well when the internet connection was strong
Resolution - Ran the dependency:resolve command again, and it was successful, without any Errors

15.          Getting the following Error when deleting and re-importing the bdd project
Error - unbound classpath variable 'm2_repo
Cause - Eclipse is not able to locate the path of the local mvn repo
Resolution - The below steps work to solve this issues
·       Open the Eclipse Preferences [Window - Preferences]
·       Go to [Java - Build Path - Classpath Variables]
·       Click New and set its name as M2_REPO
·       Click Folder and select your Maven repository folder. For example, my repository folder is C:/Users/user/.m2/repository
·       Rebuild the Project.

16.            No need to run these commands
mvn compile
mvn clean install
mvn clean

17.          Error - archive for required library cannot be read in eclipse
·       This generally happens when you are importing projects, which has external jars [added via maven POM or via direct import]
·       The first thing to try is delete those external jars and their folders, and then re-import them
·       Then in Eclipse, go to Project > Clean Project [Ensure that Build Automatically is checked]
·       If this does not resolve, then see if the jars got corrupted during copy/import, then replace them with original/valid jars

18.          Avoid having multiple versions of the same jars in the projects - only have the required version and delete the rest.

19.          If you get Errors like 'Source Not found' or 'Attach source', or 'NoClassDefFoundException' it generally means some jar is missing and not there in your build path, so find that jar, and just add it to your build path

20.          Split method in Java has a bug!
·       When we use a split function, ideally, if we don’t specify any limit, it should return all the tokens in the string, but it does not, if you have multiple delimiters in the end with empty tokens. 
·       For example in a | delimited message ("ASDAS|ASDASD|AA||||ASS|||||"), the last empty tokens would be ignored.
·       To fix this use the limit as -1
·       String[] token = sampleMsg.split("\\|" , -1);

21.          Always use string.isEmpty() method to check if the string is empty or not. 
1.    Never use null or any other method. Even if the variable is not a String, convert it to String via toString and then use isEmpty().
2.    Though a lot of people would frown upon this idea, but its simple, effective, and very easy to remember and can be implemented by a rookie in your team
22.          Ensure that you use JDK [and not JRE] in your Project Build Path

23.          Apache POI –
When adding apache poi in the dependency tree ensure to add dependencies for "poi-ooxml" and "poi-ooxml-schemas" as well, as some of the base classes for apache poi use these jars, and otherwise we would not be able to use certain classes like XSSF.

24.          If QCUtils is not working in UFT
·       Try checking the Registry values for this key.
·       'HKEY_CURRENT_USER\Software\Mercury Interactive\QuickTestProfessional\MicTest\QEEE'. 
·       This key had the parameter 'ExternalExecutionSupported', so either set it to Yes or delete it.
 
 
Other Hacks -
  • Error: Could not find PKIX Certificate Path when connecting to Artifactory.
    • Problem: When trying to run any maven commands on windows machines, sometimes we get this error where we are not able to connect to Artifactory or any Central Repo in Enterprise setups. This error will not come on your home computer but its one of the perks of working in a big Co.
    • What its not: This problem is not related to your Artifactory credentials or API Keys, or git or bitbucketor even the maven Settings.XML; although thats what you might be lead to think.
    • Cause: The problem is related to outdated Java Security Certificates or the use of incorrect ones. This happens when the java pkg gets upgraded or the one that you currently have installed does not have the required certificates. So the solution really lies in updating the security certificate file (cacertificates file in jdk dir).
    • Sol 1: Manually find and download the latest certificate and then update the cacertificates file, and then import them via the usual 'keystore' import command that you can easily google. The prob with this approach is that it needs Admin rights to edit the cacertificates file, and you will not get that ever in a big Co - another perk. So this method is DOA.
    • Sol 2: If your jdk package has recently been upgraded, then you might be lucky enough to get the latest java cacertificates files which will hopefully have the correct certificates added, and you will have to re-point your JAVA_HOME and M2_HOME and PATH variables to this new jdk pkg.
      • But that also needs Admin rights, so you will not be able to do that also. Sometimes some Cos have support teams that give you temp Admin rights, which might save the day for you, if not, read on...
      • What you can do is reset the Env Variables like JAVA_HOME and M2_HOME and PATH to new values for the current session via CMD prompt. This will work only till the time this CMD prompt is open, and all changes will be lost when you close it, and you will have to re-do these. The steps are:
        • SET JAVA_HOME=<new path>
        • SET JDK_HOME=<new path>
        • SET PATH=<new path>;%PATH%
        • Remember to append to the PATH variable otherwise it will overwrite and remove all the other values in it.
        • No need to change the variables for Maven
        • This should point your current session to the new jdk pkg folder which has the correct certs file.
    • Sol 3: Create a new folder for JDK pkg where you would have admin rights and then re-point all the variables, including Maven based, to this new folder. This approach would be helpful if you are trying to update the existing certs file with the new certs



20.11.15

Configure QTP to work with Firefox

Steps to configure QTP to work with Firefox 10.0.3, so that QTP is able to identify objects on Firefox.

  • Install QTP and Un-install any previous instances of Firefox
  • Install Firefox 10.0.3 by opening the file "WX7-FireFoxESR-10-0-3-R1.EXE" in "Run as Admin" mode
  • Restart the system
  • Install the QTP Patches in the following sequence:
    • a. QTPWEB_00090.EXE
    • b. QTPWEB_00092.EXE
  • Info about installed Patches would be available at: C:\Program Files (x86)\HP\QuickTest Professional\HotfixReadmes
  • Restart the system
  • Open: C:\Program Files (x86)\HP\QuickTest Professional\bin\Mozilla\Common\install.rdf
  • Copy the em:ID for QTP, at the top of the file, not for the Firefox itself.
  • Create a new empty file with this ID as the file name, do not give any extension to this file. Eg: {9F17B1A2-7317-49ef-BCB7-7BB47BDE10F8}
  • Enter this line in the file and click Save: C:\Program Files (x86)\HP\QuickTest Professional\bin\Mozilla\Common
  • Paste this file at: C:\Program Files (x86)\Mozilla Firefox\extensions
  • Admin privileges are need to drop this file!
  • On the desktop shortcut for QTP, right click and select "Run as Admin", let QTP get opened completely
  • Open Firefox, and install the QTP Plug-in Add-on when prompted

After this, QTP should be able to identify the objects on Firefox.
[This post needs to be updated for UFT and latest firefox versions]     

14.6.15

Miscellaneous Code, Tips and Tricks on QTP

Reusing Objects after Page Refreshes via Init

QTP web test objects go out of sync whenever the webpage Refreshes/Reloads. This means that if you held a reference to a web-object, you couldn’t could on it to work throughout your script.

'By using a .Init command after the page loads, the web-object resyncs, and the script will not break.

''Set oBrowser = Browser("version:=inter.*")
oBrowser.Navigate ""http://www.google.com"
Set oWebEdit = oBrowser.WebEdit("name:=q", "index:=0")
oWebEdit.Set "software inquisition"
oWebEdit.submit ''Page reloads
oBrowser.sync

'This resyncs oWebEdit
oWebEdit.init

'Now the next line will work
oWebEdit.Set "Bonnaroo"

--------------------------------------------------

Changing Time-out Options on Remote Machine [RDC]

[HKEY_CURRENT_USER\Software\Policies\Microsoft\Windows\Control Panel\Desktop]
"ScreenSaverIsSecure"="0"
"ScreenSaveActive"="0"
"ScreenSaveTimeOut"="999999999"

--------------------------------------------------

Quick way to generate Unique Temporary files at Runtime

Many a times we need to create all sorts of temporary files with unique names; and after the test is over they are not useful anymore. But to do this we usually ending up writing a large code for creating a new folder, then doing a lots of checks, and then finally creating a file, and then using the FilePath where ever it is that we wanted!
A quicker way of doing this and avoiding all the creation and checks for new folders is by using the Current Report Path of the test during Runtime itself, and using the DotNETFactory utility

sFilePath = Reporter.ReportPath & "\" & DotNETFactory.CreateInstance("System.DateTime").Now.ToString("ddMMyyHHMMss") & ".png"

--------------------------------------------------

Variations of SendKeys Method

This code works and has been verified!
'Create DeviceReplay object
Set objSendKey = CreateObject("Mercury.DeviceReplay")

'Focusing on the Object by clicking it
Browser("Google").Page("Google").WebElement("WebElement").Click

'Call the required function
objSendKey.SendString("Hi, Your text goes here!!!")

'Release the object
Set objSendKey = Nothing

--------------------------------------------------

How to Clear or Delete text from Edit Box

When the Set method is used, it first clears the text in the EditBox and then writes new text in the EditBox
This may also be possible by the following code:
Browser("B").Page("P").WebEdit("E").Object.Clear
What should we do if we have to just Type next to next and not overwrite the text already present

--------------------------------------------------

Keyboard Status

The Devices.Keyboard class Provides properties for accessing the current state of the keyboard, such as what keys are currently pressed, and provides a method to send keystrokes to the active window.
How can we know if CAPS-LOCK already pressed?
Before we use the numpad keys we want to verify that if NUM-LOCK already pressed.

Set Keyboard = DotNetFactory.CreateInstance( "Microsoft.VisualBasic.Devices.Keyboard", "Microsoft.VisualBasic" )

Print CBool( Keyboard.AltKeyDown )
Print CBool( Keyboard.CapsLock )
Print CBool( Keyboard.CtrlKeyDown )
Print CBool( Keyboard.NumLock )
Print CBool( Keyboard.ScrollLock )
Print CBool( Keyboard.ShiftKeyDown )
Source: http://www.advancedqtp.com/2008/04/keyboard-status/

--------------------------------------------------

Explanation of a Click

Click is not a physical click, but its just a 'Return' Event, which is why even when we see that the button has been clicked, the button would not have been actually clicked, because qtp would have sent a Return which did not get registered.
So, we may be able to correct this by changing the Replay Type

--------------------------------------------------

Use OLE Objects to get number of pages in PDF

Function GetNumPagesInPDF(FileName)
    Dim oPDFDoc
    Set oPDFDoc = CreateObject( "AcroExch.PDDoc" )

    If oPDFDoc.Open( FileName ) Then
        GetNumPagesInPDF = oPDFDoc.GetNumPages()
        Set oPDFDoc = Nothing
    Else
        GetNumPagesInPDF = -1
    End If
End Function

numPages = GetNumPagesInPDF("C:\Program Files\Mercury\QuickTest Professional\help\QTUsersGuide.pdf")
MsgBox "Number of pages: " & numPages

--------------------------------------------------

Difference between Class Name, micClass, micclass, className

Class Name: When looking through the object spy on any object, we'll see the test-object property "Class Name", which always equals to the QTP-Type of that object. So for example, the Class Name of a browser is "Browser", the Class Name of a WinButton is "WinButton".

However, if you wish to use the "Class Name" property to identify objects with Descriptive Programming syntax, you'd have to use the property micclass.

So for example, this won't work:
Browser("Class Name:=Browser")
But this will:
Browser("micclass:=Browser")"

So, this takes case of Class Name and micclass, what about the plain old Class and className properties? These properties are usually unique to Web objects.
className is a Run-Time object property of Web objects. You can test it yourself: build a symple HTML file, and add class="Something" to one of the HTML nodes. When you'll load that HTML file in a browser, and use the object spy on the relevant web-object, you'll see className="Something" in the Run-Time tab of the object spy.
class is simply the Test-Object property which equals the Run-Time property of className. Meaning that oWebObject.GetROProperty("class") will be the same as oWebObject.Object.className. They represent the same inner data, once through the Run-Time world, and once through the Test-Object world.

--------------------------------------------------
Change the default directory for Tests path for QTP

Open the registry editor (Start -> Run -> type ""regedit"".)

Navigate to the following key:
HKEY_LOCAL_MACHINE\SOFTWARE\Mercury Interactive\QuickTest Professional\MicTest

Find the TestsDirectory value. The value contains the path to the directory you want to be the default test script directory. Edit this value to have your desired path
Right click on TestsDirectory
Choose Modify from the menu
Enter the path into the Value data field
Click OK
Repeat steps 2 through 4 for the following key:
HKEY_CURRENT_USER\Software\Mercury Interactive\QuickTest Professional\MicTest

If the specified directory path does not exist, QuickTest Professional will open the "My Documents" directory by default.

You should not place a "\" at the end of the path.

--------------------------------------------------

Get Content from WinList Form

Window("Window").Activate
text= Window("Window").WinList("From").GetContent

2.12.14

Function to delete firefox cookies with VbScript / QTP

There is a QTP Util method to delete browser cookies, but that works only for IE.
Deleting the cookies for firefox programatically is a little tricky, specially if there are multiple profiles that you are using, but here is a function to do just that.

Function funcDeleteCookies()

''Ignoring any errors that may arise during file deletion

On Error Resume Next

''This function will work best when firefox is closed

Call funcTerminateProcess("firefox.exe")

''Defining the list of files that need to be deleted to clear the cache

'' arrFileToDel = Array("compatibility.ini","cookies.sqlite","cookies.sqlite-shm","cookies.sqlite-wal","extensions.ini","extensions.sqlite","formhistory.sqlite","key3.db","localstore.rdf","permissions.sqlite","places.sqlite","places.sqlite-shm","places.sqlite-wal","prefs.js","sessionstore.bak","sessionstore.js","urlclassifierkey3.txt","webappsstore.sqlite")

arrFileToDel = Array("cookies.sqlite","cookies.sqlite-shm","cookies.sqlite-wal","formhistory.sqlite","places.sqlite","places.sqlite-shm","places.sqlite-wal","sessionstore.bak","sessionstore.js","localstore.rdf","formhistory.sqlite","key3.db")


''Getting the current logged in user, because the path is user specific

sUserName = Environment("UserName")

''Location of the firefox profile folder

sProfileFolderFox = "C:\Users\" & sUserName & "\AppData\Roaming\Mozilla\Firefox\Profiles"

Set oFolderFSO = CreateObject("Scripting.FileSystemObject")


If Not oFolderFSO.FolderExists(sProfileFolderFox) Then


Call funcLogger(micWarning, "The firefox cache folder could not be located", "Cache not cleared. " & sProfileFolderFox)


Else


''Getting all the sub folders

Set oChildFolders = oFolderFSO.GetFolder(sProfileFolderFox).SubFolders

''Looping for each of the sub folders

For Each oFolder In oChildFolders

sCurrFolderName = oFolder.Name


''Generally its enough to clear the cache from the default folder, which is what we are checking below

If InStr(1,LCase(sCurrFolderName),".default",1) Then

''Deleting the files

For i = 0 To UBound(arrFileToDel) - 1
oFolderFSO.DeleteFile(sProfileFolderFox & "\" & sCurrFolderName & "\" & arrFileToDel(i))
Next

End If


Next


End If


''Enabling errors again

On Error GoTo 0

End Function

3.7.14

Transformation from QTP to Selenium

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


Transformation from QTP to Selenium

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")
 
 
 

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")