Custom Search

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