Skip to main content

Posts

Showing posts with the label qtp

Is it sane to compare Selenium with QTP?

I have seen many articles which compare Selenium (1 or 2) with QTP (or other commercial tools). But these articles miss very basic point that Selenium is a library available in variety of language while QTP has entire gamut of tools with it. So if you were to really compare QTP with Selenium then comparison should be based on the library of languages which is offered either of these tools, which in my opinion Selenium wins outright over QTP. My only intention of writing this post is not claim Selenium victory of QTP but to demonstrate how badly Selenium is compared with QTP at times. There might be things QTP would be good at doing (I left QTP long ago hence can not name any) but to disregard Selenium on the factors I listed herein is highly biased. Object spying - Sure, you have QTP recorder which does it for you but don't forget that you can test object locator using Selenium IDE and it is not limited to using only Selenium IDE. Firebug with Firefox can be used...

Test Automation Recovery Scenarios: how much recovery

This article is not specific to QTP but elaborates a more general problem with functional test automation. I caught the fancy of recovery scenarios when came across such feature in QTP. QTP's motive is to recover from problems of unexpected pop up windows (though concept itself is contradictory and requires you to know object properties of unknown window in advance!) .Though soon realized that it is more of marketing gimmick than of being of much importance to automation it self. Some thing which always puzzled me was how much of such scenarios to use. While under going In house QTP training we were told to even check presence of objects before exercising them. This is to make sure that QTP does not throw any pop up error during test case execution. (at least this is what we were told during training). Later I realized that using QTP properties could be to order QTP do what is intended (though in a limited manner). This idea of checking every object before test freaked me out. I ...

Working With FCK editors

I had troubles working with FCK editors using QTP. As these editors are recorded as “WebElement” it is not possible to perform “Set” operation on them I came across two posts which talk about dealing with this issue,   One is of Tarun’s where in talks about using “object” as well as “DeviceReplay” methods which could be used to simulate control on FCK editor He suggests not using “object” for browsers other than IE as it is supported only in IE     Browser ( " testB " ). Page ( " testP " ). Frame ( "Frame" ). WebElement ( " WebElement " ). object . innerText = " Text ” Browser ( " testB " ). Page ( " testP " ). Frame ( "Frame" ). WebElement ( " WebElement " ). object . innerHTML = "<h1> T ext</h1> ”     While other method uses object “DeviceReply” object...

Strange QTP Errors and Possible Solutions

Herein I have listed couple of error which I encountered while working with QTP. Some of these are very cryptic and you just can not guess about their Raison d'être. I have listed these errors hoping it would help a new bird. Error while opening Test On Debug Error with Function Error while using a function whose definition was not available in Action Unable to work with IE Unable to recognize IE window; had to restart the browser General Run Error There have been multiple instances of General Run Error with QTP; they just don’t let u know as to what went wrong. On such instance is when I was mistakenly trying to check a check box which was disabled. Instead of General Run Error, there could have been a more comprehensible error like – “object is disabled…”

QTP AOM File

Here in I have got sample AOM file which invokes QTP test. This file also pushes test results to a designated folder. Herein there is no hard coding of path ant where in AOM file - ################################################## Dim qtpApp 'As QuickTest qtpApplication Set qtpApp = CreateObject("QuickTest.Application") Dim qtResultsOpt 'As QuickTest.RunResultsOptions ' Declare a Run Results Options object variable qtpApp.Launch qtpApp.Visible = True qtpApp.Test.Settings.Launchers("Web").Active = False qtpApp.Test.Settings.Launchers("Web").CloseOnExit = True qtpApp.Test.Settings.Run.ObjectSyncTimeOut = 240000 qtpApp.Test.Settings.Run.DisableSmartIdentification = True qtpApp.Test.Settings.Run.OnError = "Dialog" qtpApp.Test.Settings.Web.BrowserNavigationTimeout = 60000 qtpApp.Options.Run.RunMode = "Fast" qtpApp.Options.Run.ViewResults = True qtpApp.Options.Run.MovieCaptureForTestResults = "Never" qtpApp.Options.Web....

Reading Outlook Contents From VB Script

There are instances when an application involves mail delivery for certain app features. one way to automated this is to hook with Outlook and read content of mail (though I am not very comfortable with this approach anyways!) #################################### 'Get the Count of Items in Inbox Set app = CreateObject("Outlook.Application") Set nameSpace = app.GetNamespace("MAPI") Set MyFolders = nameSpace.GetDefaultFolder(6) MsgBox MyFolders.Items.Count 'Read unread items in Inbox Set cols = MyFolders.Items For each mail In cols If mail.unread Then MsgBox mail.subject MsgBox mail.sendername MsgBox mail.body mail.unread=false End If Next ####################################

VB Script and ADO DB

VB Script can be used to establish db connection. This is very useful in QTP for writing db test cases. DB connection can be established for both SQL Server Authentication as well as Windows Authentication - ######################################### Function Func_dbConnect On Error Resume Next 'Creating the Connection Object set cn = CreateObject("ADODB.Connection") 'Setting the Data Source strCS = "Driver={SQL Server}; Server=1.1.1.1; Database=GSBREG_021010; UID=us; PWD=us;" 'Open Connection cn.Open strCS If (Err.Number 0) Then MsgBox("Login Failed") End If Set Func_dbConnect = cn End Function Sub ExecuteSQLQuery Set cn = Func_dbConnect() 'Creating RecordSet Object Set rs = CreateObject("ADODB.recordset") rs.CursorType = 2 'SQL query FetchAcademicLevels = "Select even_id from allocation_event"_ ...

VB Script and Square Brackets '[]'

I had tough time working with vb script and square brackets '[]'. Looks like square bracket has special meaning when it comes to regular expression in vb script. I was trying to write DP for check box collection on page as - ****************************************************************************** Browser("name:=.*").Page("title:=.*").WebCheckBox("name:=publishedSectionId[0]").Set "ON" ****************************************************************************** Execution of this line resulted in following error - ****************************************************************************** "Cannot identify the object "[ WebCheckBox ]" (of class WebCheckBox). Verify that this object's properties match an object currently displayed in your application." ****************************************************************************** I wonder if this error makes any sense, any ways problem is with square bracke...

Execute QTP Tests from AOM file

Herein I have got Sample QTP - AOM file. Such sample files are easily available on net but they hard code test path as well as result path. In this sample file I am going to read test path and results path dynamically from with in driver script, which would make script more portable Dim qtpApp 'As QuickTest qtpApplication Set qtpApp = CreateObject("QuickTest.Application") Dim qtResultsOpt 'As QuickTest.RunResultsOptions ' Declare a Run Results Options object variable qtpApp.Launch qtpApp.Visible = True qtpApp.Test.Settings.Launchers("Web").Active = False qtpApp.Test.Settings.Launchers("Web").CloseOnExit = True qtpApp.Test.Settings.Run.ObjectSyncTimeOut = 120000 qtpApp.Test.Settings.Run.DisableSmartIdentification = True qtpApp.Test.Settings.Run.OnError = "Dialog" qtpApp.Test.Settings.Web.BrowserNavigationTimeout = 60000 qtpApp.Options.Run.RunMode = "Fast" qtpApp.Options.Run.ViewResults = True qtpApp.O...

QTP Glitches So Far...

Well, I have started work on QTP after having worked on couple of functional test automation tools like – Selenium and Test Complete. My first impression with QTP has not been very positive; herein I have listed few glitches I experienced so (I can only hope this list not overgrowing with time) No Refactor of code – so if u modify a function name in one place it has to be updated manually in all function calls “General Run Error” – try to check a check box which is disabled and you receive “General Run Error”! Can’t it say object is disable There have been other mysteriously intermittent instances of “General Run Error” about whom I am still groping in dark If used ExecuteFile to get function definition in Action then there is no way to jump to function definition from action. Function has to be opened manually. (I don’t associate function library as it is going to hardcode path to function) While running QTP tests on a System it can not be used for any other task, QTP keeps b...

Initial QTP Scripts in CVS

In a QTP Test following files should be committed to cvs/svn – In Action – ObjectRepository.bdb Resource.mtr Script.MTS Root Folder – Default.xls Test.tsp Out of these files only “Script.MTS” is used by QTP tests for My App, but QTP still needs other files to open test, hence I had to add those as well. THanks, Tarun K

Deallocating memory in VB Script

I came across a few articles which talk about setting objects to 'Nothing' after its usages to release memory though I did not find any specific pointer about normal variables. I variable should be set to 'Empty' to deallocate memory, i.e. ****************************** Dim aVariable aVariable = 1 aVariable = Empty MsgBox IsEmpty(aVariable) Dim aObject Set aObject = CreateObject("Scripting.FileSystemObject") Set aObject = Nothing MsgBox aObject Is Nothing ****************************** For more on this refer here commented on - 16th Feb 2010 Looks like some one has different thought here

How to Avoid Hard coding of Paths in QTP Tests

We should avoid hard coding of paths in tests as this adds to portability of test from one machine other. Consider an action having following statement – Execute File (D:\GSB\QTP\fucntion\test.vbs) When tests are ported on a different machine then there is no guaranteed about drive mapping being same. To over come this, we can read path run time instead of hard coding it; as following - Make sure assignment of Global is first action as only then Run Time Env file would be available for usage. THanks, Tarun K