Custom Search

Friday, October 14, 2011

QTP automation for testing .Net applications developed using Infragistic Components

Infragistics is mainly concentrating presentation layer of any software application.
They are developing many user-friendly UI (User Interface) Controls such as Treeview control.
NetAdvantage is their product that can be used in .net applications.
QTP (Quick Test Professional) won't recognize/identify the controls in any application which is developed using NetAdvantage even when QTP is equipped with .net add-in.
So, we should go for extending capability of .net add-in to make QTP recognize these NetAdvantage components.
Infragistics is providing TestAdvantage for this purpose.
We need to use this TestAdvantage in addition to .net add-in along with QTP.
We may face many difficulties when start using TestAdvantage.
To minimize the issues we need to follow below things.

1. We should follow the below installation order strictly.
QTP installation->.net add-in installation->TestAdvantage installation
2.Version of TestAdvantage should be exactly same as version of NetAdvantage. Even advanced version is not acceptable.

Required Steps/Processes to follow for doing testing using test automation tool QTP

 I am explain the steps or processes that are required for doing testing using test automation tool QTP(Quick Test Professional).

  • Before starting actual automation task, we should do tool evaluation and feasibility study to make sure QTP is the appropriate tool for automating test cases of our application. It can be done by selecting few sample modules/screens/flow from the application/test cases and create simple QTP scripts to make sure QTP will recognize the objects in our application As part of Test driven development, we can ask the application development team to give proper name or any other identification properties for the objects, if our feasibility study reveals some difficulty for QTP to recognize the objects.
  • As I mentioned earlier, we should start our actual automation work only after completing some basic manual testing to make sure the application is stable and in working condition.
  • QTP developers should review the Test cases and update it to specify what are the test cases that can be automated. Because ideally it is not possible to automate all the test cases. The reason may be, difficulty in navigation or object identification issue or difficulty in verifying the result. If possible, the manual test cases can be rearranged to have separate automation test cases.
  • Once after reviewing all the test cases and after getting familiar with the application we can design the automation frame work for our needKeep separate instance of application specifically for the purpose of developing automation scripts. It will avoid any unnecessary mess up with manual testing processes.Set up proper QTP development environment with required Add-in and with any add-in extensibility. If many people are going to involve in the development activities then we need to clearly document the responsibility of each person and the approach for sharing the scripts. If application is installed in remote machine then QTP also should be installed in remote machine. Because QTP will not recongnize the objects of application in remote session.
Set up proper object identification properties in QTP IDE.
  1. Once after completing all the above basic steps, the first development task should be adding all the required Test Objects/properties to the Object repository It can be done by recording or by manually adding the objects to Object repository. If you specify any object using DP (Descriptive Programming) remember to document it.
  2. Once after adding all the objects, rename them to have a unambiguous/meaningful name.
  3. Based on your design of automation framework, create reusable actions and vbscript functions using step generator or keyword view or expert view or using Active screen.
  4. Using these reusable actions prepare a sample/base script for executing few test cases. And then test it to make it error free.
  5. Once after completing the above mentioned sample script, do parametrization (data driven testing) for executing multiple iterations.
  6. Add checkpoints to verify the expected results.
  7. Use appropriate Regular expression to make sure the script runs in all scenarios even when some properties are getting changed dynamically in particular pattern
  8. Add the Recovery scenarios to handle any unexpected behavior of the application.
  9. Use Environment variables to avoid any hard coded values in the script.
  10. Do dry run for this sample script and debug the issues in the automation script and fix them
  11. Do the above steps for all the test cases
  12. Create a Driver script which will call all the test scripts.
  13. Complete dry run for the Driver script.
  14. Prepare .vbs script using Automation Object Model to run the QTP scripts in other environments also with same settings.
  15. Run the scripts in desired environment.
  16. Analyze the test results
  17. Report the bugs/defects in the application once after completing the analysis.
  18. Once after completing functional testing, select few essential scripts and store them separately for the future Regression Testing.

Friday, September 30, 2011

Lock your PC automatically after the execution of Scripts.

Use the following Script and run

Set obj = CreateObject("WScript.Shell")


sCmnd = "%windir%\SYSTEM32\rundll32.exe user32.dll,LockWorkStation"

obj.Run sCmnd, 0, False

Wednesday, May 11, 2011

How to avoid System lock while QTP is running

You can avoid the System lock by Following steps
1. copy & Paste below code in notepad
Dim WSHShell
Set WSHShell = WScript.CreateObject("WScript.Shell")
WSHShell.SendKeys "{NUMLOCK}"
2. Save as keypress.vbs file
3. Schedule in microsoft scheduler (Start> Controlpanel> Scheduled Tasks> Add Scheduled Task) map the .vbs file
4. Schedule for every 1or 2 min for Required hours...

OR
You need to ask System Admin to remove the autolock?

OR

Download and Install caffeine software.





QTP - How to write Send keys

Dim WSHShell
Set WSHShell = WScript.CreateObject("WScript.Shell")
WSHShell.SendKeys "{NUMLOCK}"

List of New Features in QTP 11

Here is the complete list of new features that are available in QTP 11


Good Looking and Enhanced Results Viewer
The new improved results viewer provides an executive summary page with summary data, pie charts and statistics for both the current and previous runs and a quick link to the previous run results.

Easy Regular Expressions
You can now create reg ex with the help of syntax hints. Regular Expression Evaluator is available to test regular expressions that you have created. Good One.

Load Function Libraries at Run Time
With the help of LoadFunctionLibrary statement. You can now load a function library when a step runs instead of at the beginning of a run session.


QTP 11 is Supporting  For FireFox.

Much Awaited Log Tracking is available now
QTP 11 is capable of receiving Java or .NET log framework messages from your application which can then be embedded in the run results.

test data management with Quality CenterImproved test data management when integrated with Quality Center


Web 2.0 Toolkit Applications Support
QTP 11 now supports Web 2.0 Toolkit Applications out-of-the-box similar to any other add-ins.

Silverlight Add-in
To test objects in Silverlight 2 and Silverlight 3 applications. [After installation, Silverlight Add-in is displayed in the Add-in Manager as a child add-in under the WPF Add-in]

Avoid Downtime Due to License Server Failures
Useful for concurrent license users. With redundant license servers you can create failover, so that if your main license server fails, your remaining servers maintain availability of your licenses without causing any downtime or loss of licenses for users.(More Info)

























Tuesday, May 10, 2011

QTP - How to get font size/color background color and other attributes of WebElement

Dim ctrlWebEl, objWebEl

Set ctrlWebEl = Browser("Welcome to Gmail").Page("Welcome to Gmail").WebElement("Welcome to Gmail")
Set objWebEl = ctrlWebEl.Object
sColor = objWebEl.currentStyle.color
sBackgrColor = objWebEl.currentStyle.backgroundColor
sFontSize = objWebEl.currentStyle.fontSize
sFontStyle = objWebEl.currentStyle.fontStyle
sFontFamily = objWebEl.currentStyle.fontFamily
sFontWeight = objWebEl.currentStyle.fontWeight



Connectionstrings fro all data bases

Upload attachments to Quality Center Current Run Test from QTP

Function UpLoadAttachmentToQC(FilePath)
   Set ObjCurrentTest = QCUtil.CurrentTest.Attachments
   Set ObjAttch = ObjCurrentTest.AddItem(Null)
   ObjAttch.FileName = FilePath
   ObjAttch.Type = 1
   ObjAttch.Post
   ObjAttch.Refresh
End Function

FilePath=”C:\abc.vbs”

Call UpLoadAttachmentToQC(FilePath)






Close QTP after execution from VBS Files

Private Function CloseQTP
        Set objWMIService = GetObject(“winmgmts:\\.\root\CIMV2″)
        Set colProcess = objWMIService.ExecQuery (“Select * from Win32_Process Where Name =  QTPro.exe’”)
       For Each objProcess in colProcess
          objProcess.Terminate()
      Next
     Set objWMIService = Nothing
    Set colProcess = Nothing
End FunctionCall CloseQTP

Adding Library files to QTP at run time

Dim qtApp 'As QuickTest.Application ' Declare the Application object variable

Dim qtLibraries 'As QuickTest.TestLibraries ' Declare a test's libraries collection variable
Dim lngPosition
' Open QuickTest
Set qtApp = CreateObject( QuickTest.Application ) ' Create the Application object
qtApp.Launch ' Launch QuickTest
qtApp.Visible = True ' Set QuickTest to be visible
' Open a test and get its libraries collection
qtApp.Open C:\Test1 False False ' Open a test
Set qtLibraries = qtApp.Test.Settings.Resources.Libraries ' Get the libraries collection object
' Add Utilities.vbs if it's not in the collection
If qtLibraries.Find( C:\sai1.vbs ) = -1 Then ' If the library cannot be found in the collection
     qtLibraries.Add C:\sai1.vbs 1 ' Add the library to the collection
End If

Friday, May 6, 2011

Retrive multiple column and Rows values from Excel sheet with Query

myarray=GetDataFromExcel("C:\QTPExcelTest\Excel.xls","WCH","ColName1,ColName2","VisitGroup='Prenatal Visit'")
RowCount=UBound(myarray,2)
colVal=0
For c=0 to colVal
   For r=0 to RowCount
       MsgBox myArray(r,c)
   Next
Next

Function GetDataFromExcel(strPath, strSheet, strRqfields,strWhereClause)
Dim cn
''Create connection to Excel 2003 sheet
Set cn = CreateObject("ADODB.Connection")
cn.Provider = "Microsoft.Jet.OLEDB.4.0"
cn.ConnectionString = "Data Source="&strPath&";" &"Extended Properties=Excel 4.0;"
cn.Open
If err.number <> 0 Then
   Print Err.number
End if
''' Execting Query
Query = "Select "& strRqfields &" FROM [" & StrSheet & "$] where "& strWhereClause
Set rs = CreateObject("ADODB.recordset")
Set rs = cn.Execute(Query)
If Not Rs.EOF Then
   myArray = Rs.GetRows()
End If
GetDataFromExcel=myArray
rs.close
Set rs = Nothing
cn.Close
Set cn = Nothing
End Function

Sunday, January 9, 2011

How to add all array values without using “&” symbol?

Using Join method, add all array value to one string as below.

Dim Mystring
Dim Myarray(2)
Myarray(0)="Mr."
Myarray(1)="Jhon"
Myarray(2)="Deo"

Mystring=join(Myarray)
msgbox Mystring

Difference between Smoke and Sanity Testing?

Smoke Testing : - Smoke Testing done to ensure that whether the build can be accepted for further software testing or not. Basically, it is done to check the stability of the build received for software testing.

Sanity testing : - After receiving a build with minor changes in the code or functionality, check whether it rectified the  bugs or issues and any other bugs is introduced by the changes. and also test some of the functionalities in depth to ensure that whether the requirements are met or not.

Sunday, January 2, 2011

Get the repeated character in one string

Function GetCharCount(strChar,strSearchIn)
    dim intCounter
    for intCounter = 1 to len(strSearchIn)
         if Mid(strSearchIn,intCounter,1)=strChar then
             GetCharCount=GetCharCount+1
         end if
    next
End Function
msgbox GetCharCount("s", "this is a string")

======Second method=========
str="this is a string"
msgbox Len(str)-Len(Replace(str,"s",""))