Wednesday, October 21, 2009

Enter Data in Dynamic Field in a web page

In Below function maitain Property values in Fields sheet and pass data from global sheet.

Public function Filldata(MyPage,ObjClass)
set objdesc=Description.Create
objdesc("micclass").value=ObjClass
set obj= MyPage.ChildObjects(objdesc)
objcount=obj.count
msgbox objcount
For i=0 to objcount-1
msgbox obj(i).getroproperty("name")
strObjProperty=obj(i).getroproperty("name")
intFieldsRowCounter = DataTable.GetSheet("Fields").GetRowCount
For j = 1 to intFieldsRowCounter
datatable.getsheet("Fields").setcurrentrow(j)
If Instr(strObjProperty,DataTable.Value("PropertyVal", "Fields")) > 0 Then
'MsgBox "I am in For"
On error resume next
fieldName = DataTable.Value("Field", "Fields")
msgbox datatable.Value( fieldName,"Global")
obj(i).set DataTable.Value(fieldName, "Global")
On error goto 0
Exit for
End If
Next
Next
end function

Guide Lines for clean Uninstall and Reinstall of QTP

Performing a clean uninstall/reinstall of QuickTest Professional From here on, QuickTest will be used to represent QuickTest Professional.

Note: Previous versions of QuickTest should be uninstalled before (re)installing QuickTest.

Here are the steps for a clean uninstall/reinstall of QuickTest :
1. Backup the lservrc file. This file contains licensing information. If you do not save it, you will need to reenter the license code.
For additional information on the lservrc file, including its location, refer to Document ID KM175077 - What is the lservrc file

Note:- If you are using a concurrent license, it should be located on the license server machine. However, if you find the file on your client machine, it is recommended that you back it up.

2. Backup your test scripts.
3. For QuickTest 8.2 or higher, uninstall any non-core add-ins (Control Panel -> Add Remove Programs).

Note:
Add-in versions 6.5 and below did not have a separate uninstall process.

4. Uninstall QuickTest (Control Panel -> Add Remove Programs).
5. Go to the install directory of QuickTest. The default directory is "C:/Program Files/Mercury Interactive/QuickTest Professional/" or "C:/Program Files/HP/QuickTest Professional/" .
6. Delete all the directories under this directory except for the "Tests" folder since it might contain test scripts. If you backed up the test scripts to a different directory in step 2, you can delete the Tests folder also.
7. Open the registry editor (Start -> Run -> regedit).
8. Navigate to the following registry key:

For QuickTest Professional 6.0 and above:
HKEY_CURRENT_USER/Software/Mercury Interactive/QuickTest Professional

For QuickTest Professional 6.0:
HKEY_CURRENT_USER/Software/Mercury Interactive/QuickTest Professional

9. Delete the "QuickTest Professional" or "QuickTest Professional" folder (including all the keys and values under it.) 10. Navigate to the following registry key:

For QuickTest Professional 6.0 and above:
HKEY_LOCAL_MACHINE/SOFTWARE/Mercury Interactive/QuickTest Professional

For QuickTest Professional 6.0:
HKEY_LOCAL_MACHINE/Software/Mercury Interactive/QuickTest Professional

11. Delete the "QuickTest Professional" folder (including all the keys and values under it.) 12. The HKEY_LOCAL_MACHINE/SOFTWARE/Mercury Interactive/QuickTestPro key contains license information. If you want to delete this key as well, Mercury Support recommends backing up the key first (right-click on the "QuickTestPro" key and select Export).
13. Download the MSI uninstaller from the Microsoft: http://support.microsoft.com/kb/290301
14. Run the utility to remove any QuickTest entries that are listed.
15. Delete or Rename the BHOManager.dll in C:/Windows/system32/ folder 16. Delete the following assemblies from the C:/Windows/assembly/ directory:
- Mercury.QTP.Agent
- Mercury.QTP.CustomServer
- Mercury.QTP.WpfAgeny
- policy.6.5.Mercury.QTP.CustomServer
- policy.8.0.Mercury.QTP.Agent
- policy.8.0.MngUtils

17. If the Firefox browser is installed go to Tools->Add-ons and manually remove the QuickTest Professional PlugIn 18. Reboot the machine.
19. Install or reinstall QuickTest Professional.
20. Copy the lservrc file from step 1 into the correct directory. As long as the locking code (which is machine specific) did not change, you should be able to use QuickTest Professionalional without having to re-enter the license code.

Useful information (Phone Numbers)

Thought this might be of some use for us, so sending it across.


Toll Free Numbers in India Airlines Indian Airlines - 1800 180 1407Jet Airways - 1800 22 5522 SpiceJet - 1800 180 3333 Air India -- 1800 22 7722 KingFisher - 1800 180 0101 Banks ABN AMRO - 1800 11 2224Canara Bank - 1800 44 6000 Citibank - 1800 44 2265Corporatin Bank - 1800 443 555Development Credit Bank - 1800 22 5769 HDFC Bank - 1800 227 227ICICI Bank - 1800 333 499 ICICI Bank NRI - 1800 22 4848IDBI Bank - 1800 11 6999Indian Bank - 1800 425 1400ING Vysya - 1800 44 9900Kotak Mahindra Bank - 1800 22 6022Lord Krishna Bank - 1800 11 2300 Punjab National Bank - 1800 122 222 State Bank of India - 1800 44 1955Syndicate Bank - 1800 44 6655 AutomobilesMahindra Scorpio - 1800 22 6006 Maruti - 1800 111 515Tata Motors - 1800 22 5552Windshield Experts - 1800 11 3636 Computers/ITAdrenalin - 1800 444 445 AMD - 1800 425 6664Apple Computers - 1800 444 683 Canon - 1800 333 366Cisco Systems - 1800 221 777Compaq - HP - 1800 444 999Data One Broadband - 1800 424 1800Dell - 1800 444 026Epson - 1800 44 0011 eSys - 3970 0011Genesis Tally Academy - 1800 444 888 HCL - 1800 180 8080IBM - 1800 443 333Lexmark - 1800 22 4477Marshal's Point - 1800 33 4488Microsoft - 1800 111 100 Microsoft Virus Update - 1901 333 334 Seagate - 1800 180 1104Symantec - 1800 44 5533 TVS Electronics - 1800 444 566WeP Peripherals - 1800 44 6446 Wipro - 1800 333 312xerox - 1800 180 1225Zenith - 1800 222 004 Indian Railway General Enquiry 131Indian Railway Central Enquiry 131 Indian Railway Reservation 131Indian Railway Railway Reservation Enquiry 1345,1335,1330 Indian Railway Centralised Railway Enquiry 1330/1/2/3/4/5/6/7/8/9
Couriers/Packers & MoversABT Courier - 1800 44 8585AFL Wizz - 1800 22 9696 Agarwal Packers & Movers - 1800 11 4321 Associated Packers P Ltd - 1800 21 4560DHL - 1800 111 345FedEx - 1800 22 6161Goel Packers & Movers - 1800 11 3456UPS - 1800 22 7171 Home AppliancesAiwa/Sony - 1800 11 1188 Anchor Switches - 1800 22 7979Blue Star - 1800 22 2200Bose Audio - 1800 11 2673Bru Coffee Vending Machines - 1800 44 7171Daikin Air Conditioners - 1800 444 222 DishTV - 1800 12 3474Faber Chimneys - 1800 21 4595 Godrej - 1800 22 5511Grundfos Pumps - 1800 33 4555LG - 1901 180 9999Philips - 1800 22 4422 Samsung - 1800 113 444Sanyo - 1800 11 0101Voltas - 1800 33 4546 WorldSpace Satellite Radio - 1800 44 5432 Investments/ Finance CAMS - 1800 44 2267Chola Mutual Fund - 1800 22 2300Easy IPO's - 3030 5757Fidelity Investments - 1800 180 8000Franklin Templeton Fund - 1800 425 4255 J M Morgan Stanley - 1800 22 0004 Kotak Mutual Fund - 1800 222 626 LIC Housing Finance - 1800 44 0005SBI Mutual Fund - 1800 22 3040Sharekhan - 1800 22 7500Tata Mutual Fund - 1800 22 0101 TravelClub Mahindra Holidays - 1800 33 4539Cox & Kings - 1800 22 1235God TV Tours - 1800 442 777Kerala Tourism - 1800 444 747 Kumarakom Lake Resort - 1800 44 5030Raj Travels & Tours - 1800 22 9900 Sita Tours - 1800 111 911SOTC Tours - 1800 22 3344
HealthcareBest on Health - 1800 11 8899Dr Batras - 1800 11 6767 GlaxoSmithKline - 1800 22 8797Johnson & Johnson - 1800 22 8111 Kaya Skin Clinic - 1800 22 5292LifeCell - 1800 44 5323 Manmar Technologies - 1800 33 4420Pfizer - 1800 442 442Roche Accu-Chek - 1800 11 45 46 Rudraksha - 1800 21 4708Varilux Lenses - 1800 44 8383 VLCC - 1800 33 1262 InsuranceAMP Sanmar - 1800 44 2200Aviva - 1800 33 2244Bajaj Allianz - 1800 22 5858 Chola MS General Insurance - 1800 44 5544HDFC Standard Life - 1800 227 227 LIC - 1800 33 4433Max New York Life - 1800 33 5577Royal Sundaram - 1800 33 8899SBI Life Insurance - 1800 22 9090 Hotel ReservationsGRT Grand - 1800 44 5500 InterContinental Hotels Group - 1800 111 000 Marriott - 1800 22 0044Sarovar Park Plaza - 1800 111 222Taj Holidays - 1800 111 825 TeleshoppinAsian Sky Shop - 1800 22 1800Jaipan Teleshoppe - 1800 11 5225Tele Brands - 1800 11 8000 VMI Teleshopping - 1800 447 777WWS Teleshopping - 1800 220 777 Others Domino's Pizza - 1800 111 123 Cell PhonesBenQ - 1800 22 08 08 Bird CellPhones - 1800 11 7700Motorola MotoAssist - 1800 11 1211Nokia - 3030 3838Sony Ericsson - 3901 1111

http://www.onlineradio4u.com/telugu-radio/radio-vizag-telugu-fm-online/

Find the latest File name in a Folder

We can find the lastest file name(Based on file creation date) in specified folder with below code.
In some applications at runtime files are creating and storing in share point, but we do not have control on file name and have only read only access. In these scenarios below code is helpful for latest file name capture.
Code:-
sPath=" C:\"
GetNewestFile sPath

' getting file name

Function GetNewestFile (byval sPath)
sNewestFile = Null ' init value
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set oFolder =objFSO.GetFolder(sPath)
Set oFiles = oFolder.Files
For Each oFile In oFiles
On Error Resume Next
If IsNull(sNewestFile) Then
sNewestFile = oFile.Path
Datatable.Value("FilePath","Global") =sNewestFile
msgbox sNewestFile
dPrevDate = oFile.DateLastModified
msgbox dPrevDate
Elseif dPrevDate < oFile.DateLastModified Then
sNewestFile = oFile.Path
msgbox sNewestFile
Datatable.Value("FilePath","Action1") =sNewestFile
End If
On Error Goto 0
Next
If IsNull(sNewestFile) Then
sNewestFile = ""
GetNewestFile = sNewestFile
msgbox GetNewestFile
End If
End Function

Tuesday, September 15, 2009

Get value in XML Node with XPath (Node Group)

Below code we can Get multiple values with Node path from XML file.
Set xmlDoc = CreateObject ( "Microsoft.XMLDOM")
xmlDoc.Async = "false" xmlDoc.Load ( "C:\Test1.xml")
i=0
For Each personneElement In xmlDoc.selectNodes ( "/Modules/Module/Options/Option/Skus/Sku/Price/AssociatedPrices/Price/AssociatedPrices/Price/Type")

If personneElement.text = "Expectedvalue" Then
MsgBox personneElement.text
' we can get Two previous node value with below statement
MsgBox personneElement.PreviousSibling.PreviousSibling.text
' personneElement. i= i+1
End If
Next
msgbox i

Reference :-
http://techdos.com/content/view/77/74/

Monday, September 14, 2009

XML file Conversion from ANSI to Unicode

Some XML files which are saved in ANSI Encoding type are not fully open in IE browser. Those files we have to save as in Unicode Encoding Type then we can open those files without errors. We can do above action in QTP with below function.

Function convertANSItoUTF8(input_file,output_file)
Const adTypeBinary = 1
Const adTypeText = 2
Const bOverwrite = True
Const bAsASCII = False
Dim oFS : Set oFS = CreateObject( "Scripting.FileSystemObject" )
Dim sFFSpec : sFFSpec = oFS.GetAbsolutePathName( input_file )
Dim sTFSpec : sTFSpec = oFS.GetAbsolutePathName(output_file )
Dim oFrom : Set oFrom = CreateObject( "ADODB.Stream" )
Dim sFrom : sFrom = "Windows-1252"
Dim oTo : Set oTo = CreateObject( "ADODB.Stream" )
Dim sTo : sTo = "utf-8"
If oFS.FileExists( sTFSpec ) Then oFS.DeleteFile sTFSpec
oFrom.Type = adTypeText
oFrom.Charset = sFrom
oFrom.Open
oFrom.LoadFromFile sFFSpec
msgbox oFrom.Size & " Bytes in " & sFFSpec
oTo.Type = adTypeText
oTo.Charset = sTo
oTo.Open
oTo.WriteText oFrom.ReadText
msgbox oTo.Size & " Bytes in " & sTFSpec
oTo.SaveToFile sTFSpec
oFrom.Close oTo.Close
End Function

Another Way:-

Const ForReading = 1, ForWriting = 2
Const TristateUseDefault = -2, TristateTrue = -1, TristateFalse = 0
Set fso = CreateObject("Scripting.FileSystemObject")
XMLPath= "C:\File.xml"
fso.CreateTextFile XMLPath ' Create a file.
Set f = fso.GetFile(XMLPath)
Set ts = f.OpenAsTextStream(ForWriting, TristateTrue)
ts.Write Browser("Browser").Page("Page").WebXML("ObjectName").GetData
ts.Close

Saturday, August 8, 2009

In Webservice Response, Convert XML Unicode from UTF-16 to UTF-8

ConvertResponse= Replace (WebServiceResponse.ToString(),"utf-16","utf-8")

Tuesday, July 28, 2009

In Web table, find dynamic Links / Web Check boxes count and perform action on specified links

In Webtable first finding the Row count, Next Column count and getting the number of links / Webcheck boxes in a perticular cell based on the expected value matching with displayed value. Then performing the action on perticular Link with the index.

Code:-
Links
Dim objWebTable
Dim intRowCount , intRow, intColumnCount, intColumn, intLinksCount, intItemIndex, strLinkItem, blnExitFor

blnExitFor =False

Set objWebTable = Browser("Browser Name").Page("Page Name").WebTable("Web Table name")
intRowCount = objWebTable. RowCount
For intRow =1 to intRowCount
intColumnCount = objWebTable.ColumnCount(intRow)
For intColumn =1 to intColumnCount
strActualString = objWebTable.GetCellData(intRow, intColumn)
If UCase(Datatable.Value("expectedvalue","Global"))= UCase(strActualString) Then
Msgbox "strActualString - - "& strActualString
intLinksCount = objWebTable.ChildItemCount (intRow, intColumn, "Link")
For intItemIndex =0 to intLinksCount - 1
Set strLinkItem = objWebTable. ChildItem(intRow, intColumn, "Link" , intItemIndex)strLinkItem.Click ' Specify the required operations after clicking on linkNext
blnExitFor =True
Exit for
Next
End If
Next
If blnExitFor =True then
Reporter.Reporterevent Micdone,”Clicked on Link”, ”Clicked on link”
Exit For
End if
Next

WebCheckBoxes :-
In the below code covered for dynamic check boxes turn on functionality.
Scenario:- In Webtable check boxes are displaying Under one column (fixed) and number of check boxes are depended on number of rows.

Set objWebTable = Browser("Browser Name").Page("Page Name").WebTable("Web Table name")

intRowCount = objWebTable.RowCount ' objWebTable. RowReporter.ReportEvent micDone," Web table Row count"," No of Rows in the web table : - " & intRowCount
msgbox intRowCount
For intRow =2 to intRowCount
' msgbox intRow
Reporter.ReportEvent micDone," Web check box Row number ","Turned on Web Check Box , Row Number : - " & intRow
Set strLinkItem = objWebTable.ChildItem(intRow,0,"WebCheckBox",0)
strLinkItem.Set "ON"
Next

Friday, July 24, 2009

Settings for Flex Application Automation

Find the information for Install and Configure Flex Automated Testing in the below link.
http://www.adobe.com/support/documentation/en/flex/3/releasenotes_flex3_fb.html#install_automated_testing

For example find the application in the below link.
http://examples.adobe.com/flex2/inproduct/sdk/flexstore/flexstore.html

Tuesday, June 30, 2009

Error Numbers and Description

Error Number -- Description
-2147220984 -- Object is Disabled

-2147220990-- Object Not Found Or Text input disabled

-2147220975-- The statement contain one or more invalid function arguments

-2147220983-- Required item is not available (In List box)

Wednesday, June 17, 2009

Handle the Invisible Objects With QTP Code

Some times in .Net (Ajax UI) applications, Invisible objects are identifying with QTP.In this case Exist mehtod is not working as expected.

if Borwser("BName").Page("PageName").WebElement("WBName").object.currentStyle.display="none" Then
Msbbox "Object is in Hidden mode"
else
Msgbox "Object is in visbile mode"
End If

Wednesday, May 27, 2009

General Tips

1. How to put focus on a particular Object?

Window(" Window Name"). winEdit("EditBox Name"). Object.focus

2. Can we merge two or more lines lenght of text into one variable?

Myvar="first line of text"&_
" Second Line of Text"&_
" third Line of Text"&_
" 4th Line of Text"&_
----
----
" Nth Line of text"

msgbox Myvar

Output:- "first line of text Second Line of Text third Line of Text 4th Line of Text ---- ----Nth Line of text"

3. How to capture check Point Result Or Run Action Result?
For check Point:-
CheckPointRunResult=Browser("BrowserName").Page("Page name").WebButton("Name").Check (CheckPoint("Checkpoint Name"))
Msbgox CheckPointRunResult

For Run Action:-
strRunActionResult=RunAction ("ActionName", oneIteration)

4. How to send mail from QC?

Set QCconn = QCUtil.TDConnection
QCconn.SendMail ToList,From,Subject,Body,"", "html"

5. How to Reboot a windows system with QTP code ?

Plese find the code in below Link. http://haripotter.wordpress.com/2008/08/06/how-to-reboot-a-windows-system-using-wmi/

6. how to change default synchronization timeout value with code?

Default Timeout (Test Settings for Object):- Sets or retrieves the delay for finding objects. DefaultTimeOut is a per-test setting

Setting("DefaultTimeout") = 24000 ' Milliseconds

Maximum time in milliseconds to wait before it is determined that an object cannot be found.

Page Load time:-Sets or retrieves the setting for the add to load time option. DefaultLoadTime is a global testing setting. Changes to this setting will be maintained for the remainder of the current testing session.

Setting("DefaultLoadTime") = seconds

'Indicates the time to add, in seconds, to the load time during recording. This option is a safeguard that prevents the test from failing in the event that the amount of time it takes for a page to load during the run session is higher than the amount of time it took during the record session.

Screenshot:- Determines when QuickTest captures and saves images of the application during the test run to display them in the test results.

Setting("SnapshotReportMode") = CaptureValue

' Indicates when the images are captured. The value can be one of the following:
0 - always captures images.
1 - captures images only if an error occurs on the page.
2 - captures images if an error or warning occurs on the page.
3 - never captures images.
Default = 1.

Web Timeout:- Sets or retrieves the delay for navigating to a URL address. WebTimeOut is a per-test setting.

Setting("WebTimeout") = Seconds ' Maximum time in seconds to wait before it is determined that a URL address cannot be found.

WEbPackage :- Configures how to run mouse operations—using browser events or using the mouse. ReplayType is a global testing setting.

Setting.WebPackage("ReplayType") = Setting

Indicates how mouse operations should be run. The value can be one of the following:
1 - Runs mouse operations using browser events.
2 - Runs mouse operations using the mouse.

Convert DATE Format from any Format to Required Format

With below tow ways we can convert date fromat from current format to required date data type format.
way 1:-
Code :-
Dim xlsCurrentDate
Set xlsCurrentDate=GetObject("","Excel.Application")
MsgBox xlsCurrentDate.Text("5/27/2009", "YYYY-MM-DD")
Set xlsCurrentDate=Nothing

OUTPUT :- 2009-05-27

way 2:-
dim Val, DateConvert, formatDate
Val="5/27/2009"
DateConvert=Cdate(Val)
formatDate=Year(DateConvert)&"-"&Month(DateConvert)&"-"& day(DateConvert)
msgbox formatDate

OUTPUT :- 2009-05-27

Tuesday, May 12, 2009

How to get Test parameter value?

I got the information in the below site for Test parameter creation and get value.
syntax for Test paramter value retrive: TestArgs ("Test Parameter Name")

http://qtp.blogspot.com/2007/11/qtp-test-parameters_11.html

Sunday, May 10, 2009

How to "Save As" a existing Script with QTP code?

We can "SaveAs" saved script in Local machine and in Quality Centre with below code.

Dim QTPApp 'As QuickTest.Application ' Declare the Application object variable
Set QTPApp = CreateObject("QuickTest.Application") ' Create the Application object
QTPApp.Launch ' Start QuickTest (if not launched)
QTPApp.Visible = True ' Make it visible
QTPApp.Open “C:\Test1”,True ' Open the test in Edit mode
QTPApp.Test.SaveAs “C:\SaveAsTest” 'Save it with a temporary name (override existing temporary test)
Set QTPApp = Nothing ' Release the Application object

Import file with Pathfinder command.

We can import files (Excel, VBS, XML, etc.) from Local machine and Quality Center to QTP.

First we have to do settings in QTP with below navigation
Tools --> Options --> Folders and click on “+” and add specified folder path.

In code wherever we are using “Import” command there use below code.


Dim QTPApp, SearchPath
Set QTPApp = CreateObject("QuickTest.Application") ' Create the Application Object
QTPApp.Launch ' Start QTP

QTPApp.Folders.Add(“C:\FolderNmae")' Add the folder for Search list

SearchPath=pathfinder.Locate("FileName.xls") ' Locate the folder Path
datatable.ImportSheet SearchPath,1,1
set QTPApp =nothing 'Release the Application Object

Get specific node value from XML file.

We can get parent and child node values with below code.

Val=GetNodeValue ( “C:\XMLfile.XML”,"ParentNodeName","ChildNodeName")
msgbox UBound(Val)

Function GetNodeValue(XMLFilePath,ParentNode,ChildNode)
Dim Obj_Xml,str_ParentNode,list_childs
Dim i,j,str_ParentNodeCnt,str_result()

set Obj_Xml=createobject("MSXml2.DOMDocument.3.0")
Obj_Xml.load XMLFilePath
set str_ParentNode=Obj_Xml.getElementsByTagName(ParentNode)
str_ParentNodeCnt=str_ParentNode.length
ReDim str_result(str_ParentNodeCnt)
msgbox str_ParentNodeCnt
For i=0 to str_ParentNodeCnt-1
set list_childs=str_ParentNode(i).childnodes
for j=0 to list_childs.length-1
If list_childs.item(j).nodename=ChildNode then
str_result(i)=list_childs.item(j).text
Exit for
end if
next
Next
GetNodeValue=str_result
End Function

Monday, April 13, 2009

QTP Reference snapshot (Short Cuts)

Please use the below link for QTP Quick Referece for QTP easy usage.

URL:

http://automatedchaos.googlepages.com/QTPquickreferencecardv1.1a.pdf

Wednesday, April 8, 2009

Configure Quick Test Pro Views and Panes at Run time

We can Configure test pane view (ExpertView or KeywordView), Debug View, Data Table, Active Screen and we can maximize QTP Window with the below code.

Dim QTPApp
' Create Object for QTP application
Set QTPApp = CreateObject("QuickTest.Application")

' Launch QuickTest
QTPApp.Launch

' Display the Expert View
QTPApp.ActivateView "ExpertView"

' Display the Active Screen pane
QTPApp.ShowPaneScreen "ActiveScreen", True

' Displaye the Data Table pane
QTPApp.ShowPaneScreen "DataTable", True

' Display the Debug Viewer pane
QTPApp.ShowPaneScreen "DebugViewer", True

' Maximize the QTP Window
QTPApp.WindowState = "Maximized"

'Display the QTP Window
QTPApp.Visible = True ' Make the QuickTest window visible

wait(5)
' Release the Object
Set QTPApp = Nothing

Tuesday, April 7, 2009

HP QTP (Quick Test Pro) and HP QC (Quality Center) Examination details

Please find the details below for HP Certified Professional Certification.

First book slot in any Prometric Center and take the examinations at that slot allocated time.

HP Quality Center 9.2 (QC 9.2) Exam details:-

Exam Code : HP0-M15
Number of Questions: 90 (all Multiple Choice Questions)
Exam Duration : 3 Hours
Pass Percentage : 70 %
Fees : $ 60

Please find More details in the below URL
ftp://ftp.hp.com/pub/hpcp/epgs/HP0-M15_EPG.pdf

HP Quick Test Professional 9.2 (QTP 9.2) Exam details:-

Exam Code : HP0-M16
Number of Questions: 58 (all Multiple Choice Questions)
Exam Duration : 2 Hours
Pass Percentage : 70 %
Fees : $ 60

Please find More details in the below URL
ftp://ftp.hp.com/pub/hpcp/epgs/HP0-M16_EPG.pdf

Monday, April 6, 2009

Find Number of Actions in a Test


We can find cout of actions in open QTP test with the below code
.
' Create the Application object

Set QTPApp = CreateObject("QuickTest.Application")

ActionCount=QTPApp.Test.Actions.count
Msbgox "Number of Actions : " & ActionCount

we can open QTP script and find the no of actions with the below code.

' Create the Application object
Set QTPApp = CreateObject("QuickTest.Application")
' Launch QuickTest
QTPApp.Launch
' Set QuickTest to be visible

QTPAppVisible = True

' Open a test

QTPApp.Open "C:\Test1", False, False
msgbox QTPApp.Test.Actions.count

Wednesday, March 18, 2009

Get the data from clipboard

We can get last copied data (text) with following code.

Set objInternetExplorer = CreateObject("InternetExplorer.Application")
objInternetExplorer.Navigate("about:blank")
msgbox objInternetExplorer.document.parentwindow.clipboardData.GetData("text")

OR

Set objClipboard= CreateObject("Mercury.Clipboard")
objClipboard.Clear
objClipboard.SetText "use variable for the Copied text"
MsgBox objClipboard.GetText

Tuesday, March 17, 2009

Read EMail Body from Outlook Subfolder EMail

We can Get text of a E-Mail which is located in subfolder or inbox etc. with the below code.

'Folder Constants
olFolder=3 'Deleted items
olFolder=4 'Outbox
olFolder=5 'Sent Items
olFolder=6 'Inbox
olFolder=9 'Calendar
olFolder=10 'Contacts
olFolder=11 'Journal
olFolder=12 'Notes
olFolder=13 'Tasks

Dim objOutlook,mycount
myFolder="QTP"
Set objOutlook = CreateObject ("Outlook.Application")
Set myNameSpace = objOutlook.GetNameSpace("MAPI")
Set ClientFolder = myNameSpace.GetDefaultFolder(6)
Set myItems = ClientFolder.Items
set objSubFolder = ClientFolder.Folders
set objFolder = objSubFolder.Item(myFolder)
set subobjitem=objFolder.Items
mycount=subobjitem.count
msgbox mycount

For i = 1 to mycount
Set myItem = subobjitem.Item(i)
EmailBodyStr = myItem.Body
msgbox EmailBodyStr
Next

Refer Below link :- http://techsupt.winbatch.com/TS/T000001033009F8.html

In Windows XP - Run Commands

Run Commands are more useful. Through Run Commands we can perform specific actions with less navigations. Below Run Commands are useful in WindowsXP.

1. Accessibility Controls - access.cpl
2. Accessibility Wizard - accwiz
3. Add Hardware Wizard - hdwwiz.cpl
4. Add/Remove Programs - appwiz.cpl
5. Administrative Tools - control admintools
6. Automatic Updates - wuaucpl.cpl
7. Bluetooth Transfer Wizard - fsquirt
8. Calculator - calc
9. Certificate Manager - certmgr.msc
10. Character Map - charmap
11. Check Disk Utility - chkdsk
12. Clipboard Viewer - clipbrd
13. Command Prompt - cmd
14. Component Services - dcomcnfg
15. Computer Management - compmgmt.msc
16. Control Panel - control
17. Date and Time Properties - timedate.cpl
18. DDE Shares - ddeshare
19. Device Manager - devmgmt.msc
20. Direct X Troubleshooter - dxdiag
21. Disk Cleanup Utility - cleanmgr
22. Disk Defragment - dfrg.msc
23. Disk Management - diskmgmt.msc
24. Disk Partition Manager - diskpart
25. Display Properties - control desktop
26. Display Properties - desk.cpl
27. Dr. Watson System Troubleshooting Utility - drwtsn32
28. Driver Verifier Utility - verifier
29. Event Viewer - eventvwr.msc
30. Files and Settings Transfer Tool - migwiz
31. File Signature Verification Tool - sigverif
32. Findfast - findfast..cpl
33. Firefox - firefox
34. Folders Properties - control folders
35. Fonts - control fonts
36. Fonts Folder - fonts
37. Free Cell Card Game - freecell
38. Game Controllers - joy.cpl
39. Group Policy Editor (for xp professional) - gpedit.msc
40. Hearts Card Game - mshearts
41. Help and Support - helpctr
42. HyperTerminal - hypertrm
43. Iexpress Wizard - iexpress
44. Indexing Service - ciadv.msc
45. Internet Connection Wizard - icwconn1
46. Internet Explorer - iexplore
47. Internet Properties - inetcpl.cpl
48. Keyboard Properties - control keyboard
49. Local Security Settings - secpol.msc
50. Local Users and Groups - lusrmgr.msc
51. Logs You Out Of Windows - logoff
52. Malicious Software Removal Tool - mrt
53. Microsoft Chat - winchat
54. Microsoft Movie Maker - moviemk
55. Microsoft Paint - mspaint
56. Microsoft Syncronization Tool - mobsync
57. Minesweeper Game - winmine
58. Mouse Properties - control mouse
59. Mouse Properties - main.cpl
60. Netmeeting - conf
61. Network Connections - control netconnections
62. Network Connections - ncpa.cpl
63. Network Setup Wizard - netsetup.cpl
64. Notepad notepad
65. Object Packager - packager
66. ODBC Data Source Administrator - odbccp32.cpl
67. On Screen Keyboard - osk
68. Outlook Express - msimn
69. Paint - pbrush
70. Password Properties - password.cpl
71. Performance Monitor - perfmon.msc
72. Performance Monitor - perfmon
73. Phone and Modem Options - telephon.cpl
74. Phone Dialer - dialer
75. Pinball Game - pinball
76. Power Configuration - powercfg.cpl
77. Printers and Faxes - control printers
78. Printers Folder - printers
79. Regional Settings - intl.cpl
80. Registry Editor - regedit
81. Registry Editor - regedit32
82. Remote Access Phonebook - rasphone
83. Remote Desktop - mstsc
84. Removable Storage - ntmsmgr.msc
85. Removable Storage Operator Requests - ntmsoprq.msc
86. Resultant Set of Policy (for xp professional) - rsop.msc
87. Scanners and Cameras - sticpl.cpl
88. Scheduled Tasks - control schedtasks
89. Security Center - wscui.cpl
90. Services - services..msc
91. Shared Folders - fsmgmt.msc
92. Shuts Down Windows - shutdown
93. Sounds and Audio - mmsys.cpl
94. Spider Solitare Card Game - spider
95. SQL Client Configuration - cliconfg
96. System Configuration Editor - sysedit
97. System Configuration Utility - msconfig
98. System Information - msinfo32
99. System Properties - sysdm.cpl
100. Task Manager - taskmgr
101. TCP Tester - tcptest
102. Telnet Client - telnet
103. User Account Management - nusrmgr.cpl
104. Utility Manager - utilman
105. Windows Address Book - wab
106. Windows Address Book Import Utility - wabmig
107. Windows Explorer - explorer
108. Windows Firewall - firewall.cpl
109. Windows Magnifier - magnify
110. Windows Management Infrastructure - wmimgmt.msc
111. Windows Media Player - wmplayer
112. Windows Messenger - msmsgs
113. Windows System Security Tool - syskey
114. Windows Update Launches - wupdmgr
115. Windows Version - winver
116. Windows XP Tour Wizard - tourstart
117. Wordpad - write


InetMGR:- it opens IIS

IIS server open process :- Right click on Mycomputer--> Click on Manage in dropdown --> in computer management -> expand "Services and Applications" --> Select "Internet Information Services"

--> For services --> click on Services --> in the displayed list select the required service --> right click on same --> click on Start or Stop for service availability

Ping/? :- in Dos Promt it gives help about the commands

Friday, March 6, 2009

Get Speech (Voice) from any (typed) text with QTP

Get Speech for any Text (Typed) with below code:-


Dim message, sapi
message=InputBox("What do you want me to say?","Speak to Me")
Set sapi=CreateObject("sapi.spvoice")
sapi.Speak message

Pre requisite: Install “Microsoft’s speech API” (SAPI) in your machine.

Monday, February 16, 2009

Excel Automation : Open excel file, Sort Excel file, Delete Rows, Delete Columns, Create new excel file,copy data from one file and past in other file

In below code covered Excel Automation with the following actions:-
1) Open existing excel file
2) Sort Excel file
3) Delete Rows
4) Delete Columns
5) Create new excel file
6) copy data from one excel file and past it in another excel file.


‘ Give new excel file path for creation
NewExcelFile="C:\NewExcelFile.xls"
' Give path for Data having excel file
ExistingExcelFile="C:\ExistingExcelFile.xls"
'Represents the sorting type 1 for Ascending 2 for Desc
Const xlAscending = 1
Const xlDescending=2
Const xlYes = 1
Dim objExcel, xlBook, xlSheet, objWorkbook, objWorksheet, objRange, objRange2, oSheet , objWorkbook2
Const xlExcel7 = 39

'Create the excel object, Activate worksheet and disable alerts
Set objExcel = CreateObject("Excel.Application")
Set xlBook=objExcel.workbooks.add
Set xlSheet=xlBook.activesheet
objExcel.DisplayAlerts = False

Save new excel file
xlBook.saveas ExistingExcelFile
objExcel.Visible = True

'Open the created excel file
Set objWorkbook = objExcel.Workbooks.Open(NewExcelFile)

'Select the Work sheet based on the index ..1,2 ,3 …
Set objWorksheet = objWorkbook.Worksheets(1)

'Which select the range of the cells has some data other than blank
Set objRange = objWorksheet.UsedRange

‘Select the column to sort
Set objRange2 = objExcel.Range("B1")

Sort the Excel file in ascending order
objRange.Sort objRange2, xlAscending, , , , , , xlYes

‘Sort the Excel file in descending order

'objRange.Sort objRange2, xlDescending, , , , , , xlYes
'Set Activesheet
Set oSheet = objExcel.Activesheet
objExcel.DisplayAlerts = False
'‘Delete rows or row in the excel file
oSheet.Rows("10:30").Delete
wait(1)
Delete Column or Columns in the excel file
oSheet.Columns("C:P").Delete
wait(1)
Save Workbook
objWorkbook.Save

Set objWorkbook2= objExcel.Workbooks.Open(ExistingExcelFile)
Copy the data from used range excel file
objWorkbook.Worksheets(1).UsedRange.Copy
Past the Copy data
objWorkbook2.Worksheets(1).Range("A1").PasteSpecial Paste =xlValues
Save the files and close open files
objWorkbook.save
objWorkbook2.save
objWorkbook.close
objWorkbook2.close
set objExcel=nothing

Transfer data from text file to Excel file

Copy data from text file and past it into the excel file with the following code.This is just like transfer text from Notepad to excel file.


Const ForReading = 1, ForWriting = 2
Dim fso, MyFile,a, intLine, strExcelFilePath
strExcelFilePath="C:\SPQTP.Xls"
Set fso = CreateObject("Scripting.FileSystemObject")
Set xlObj = CreateObject("Excel.Application")
xlObj.DisplayAlerts = False
Set xlBook=xlObj.workbooks.add
Set xlSheet=xlBook.activesheet
xlBook.saveas strExcelFilePath

Set xlWB = xlObj.Workbooks.Open ( strExcelFilePath)
Set NewSheet = xlWB.Sheets("Sheet1")
xlObj.Visible = True
xlObj.DisplayAlerts = False
Set MyFile = fso.OpenTextFile("C:\SPQTP.txt", ForReading, True)

i = 0
Do While not MyFile.AtEndOfStream
' msgbox MyFile.Readline
NewSheet.Cells(i+1,1) = MyFile.Readline
i = i+1
Loop
xlWB.save
xlWB.close
set xlObj= nothing

Get Number of lines in a Text file

In Notepad we can get Count of lines with the following code. But it works fine for less than 100 kb size of Text files.

Const ForReading = 1, ForWriting = 2
Dim fso, MyFile,a, intLine
' Create Object
Set fso = CreateObject("Scripting.FileSystemObject")

' Open the file for reading
Set MyFile = fso.OpenTextFile("C:\SPQTP.txt", ForReading,True)

while(MyFile.atendofline<>true) 'read the file to the end of file
sLine=MyFile.readline()'line by line reading
n = n + 1 'increment counter
msgbox "Text :- " &sLine
Wend
msgbox "Number of lines in the text file:- "& n

' Close the file
MyFile.Close

How to Read data from Text file with QTP?

We can read text line by line from text file with the below code.

Const ForReading = 1, ForWriting = 2
Dim fso, MyFile

' Create Object
Set fso = CreateObject("Scripting.FileSystemObject")
' Create file and enter data into the created file
Set MyFile = fso.OpenTextFile("C:\SPQTP.txt", ForWriting, True)
MyFile.WriteLine "First line - - Hello world!"
MyFile.WriteLine "Second Line :-- "
MyFile.WriteLine "Third Line :-- "
MyFile.WriteLine "4th Line :-- "
MyFile.WriteLine "5th Line :-- "
MyFile.WriteLine "6th Line :-- "
MyFile.WriteLine "7th Line :-- "
MyFile.WriteLine "8th Line :-- "
MyFile.WriteLine "9th Line :-- "
MyFile.WriteLine "10th Line :-- "

' Close the file
MyFile.Close
' Open the file for reading
Set MyFile = fso.OpenTextFile("C:\SPQTP.txt", ForReading,True)

Do While not MyFile.AtEndOfStream
msgbox "Text :" & MyFile.Readline ' get data line by line
' msgbox "Text :" & MyFile.Read(15) ' get no of charecters from a line
' msgbox "Text :" & MyFile.ReadAll ' Get complete file text
Loop

Friday, February 13, 2009

Create a text file and enter data into the text file

In the below snippet code covered following actions.
1. Create a text file with “FilesytemObject”(Note pad) object.
2. Enter text in to the text file and close it.
3. Open the same and read the data .

Const ForReading = 1, ForWriting = 2
Dim fso, MyFile,a, intLine
' Create Object
Set fso = CreateObject("Scripting.FileSystemObject")
' Create file and enter data into the created file
Set MyFile = fso.OpenTextFile("c:\SuryaRead1.txt", ForWriting, True)
MyFile.WriteLine "Hello world!"
MyFile.WriteLine "Quick Test Pro "
' Close the file
MyFile.Close

' Open the file for reading
Set MyFile = fso.OpenTextFile("c:\SuryaRead.txt", ForReading,True)

For i = 1 to 2
a = MyFile.ReadLine ' Returns text line by line
MsgBox a
Next

Send Email from Outlook with QTP code

We can send E-Mail with creating Object for Outlook. In below example code we can send mail with CC, BCC recipients and Attachment.

Below is a list of all default folder constants in MS Outlook.


'Folder Constants
olFolder=3 'Deleted items
olFolder=4 'Outbox
olFolder=5 'Sent Items
olFolder=6 'Inbox
olFolder=9 'Calendar
olFolder=10 'Contacts
olFolder=11 'Journal
olFolder=12 'Notes
olFolder=13 'Tasks



'Mail sending
Dim objOutlook
Set objOutlook = CreateObject("Outlook.Application")
Set EMail = objOutlook.CreateItem(0)

SendTO="……. @......com"
SendCC="……. @......com"
sendBCC="……. @......co.in"
MailSubject="Outlook automation"
EMailBodyStr = "Out Look automation body with QTP"
EMail.to=SendTO
EMail.CC=SendCC
EMail.BCC=sendBCC
EMail.Subject=MailSubject
EMail.body=emailBodyStr
EMail.Attachments.Add("C:\SPQTP.txt")
email.Send
objOutlook.quit
Set EMail=Nothing
Set objOutlook=Nothing

In some systems we will get following error
“A program is trying to access e-mail addresses you have stored in Outlook. Do you want to allow this?”


We can handle this error with installing one third party tool in our machine. Please see the details in the below URL.

http://www.contextmagic.com/express-clickyes

If you want more details for above error refer the following sites.

http://www.add-in-express.com/docs/outlook-security-manager-addins.php

http://pubs.logicalexpressions.com/pub0009/LPMArticle.asp?ID=604

Thursday, February 12, 2009

How to handle run time errors with Recovery scenario?

First create below function in function library. In this function, if we want to add additional features like Report, capture bitmap facilities etc.

Function RuntimeErrorHandle (Object, Method, Arguments, retVal)
Dim objReference, strClassName
Set objReference = Object
strClassName = objReference.GetTOProperty("Class Name")
Reporter.ReportEvent micFail,"Runtime Error"," Runtime Error Displayed and
stoped execution -- "&" Object Name:-- " & strClassName &" - Method - "&
Method& " -- ErrorNo: -- "&retVal
Desktop.CaptureBitmap "C:\ScreenShot.png"
ExitAction "Fail"
End Function

While creating Recovery scenario select
1. “Test Run Error” as Trigger Event
2. “Any error” from Error combo box
3. “Function Call” as Recovery Operation
4. Select Function Library and then select created function and finish with further steps.

Wednesday, February 11, 2009

How to configure Mouse Operations at runtime?

Configure the mouse operations
1. Using browser events
or
2. Using the mouse at run time with "ReplayType" Property.

Example:-
1. Runs mouse operations using browser events.
Setting.WebPackage(“ReplayType”)=1
2. Runs mouse operations using the mouse.
Setting.WebPackage(“ReplayType”)=2

In some applications While entering data in WebEdit object with Set method, we will get Problem,there this is useful.

Thursday, January 22, 2009

How to know the Action Name, Operating system, OS Version, Test name ,Script Executer Name, etc… at script runtime?

strActionname = Environment.Value("ActionName")
strOperatingSystem = Environment.Value("OS")
strOSVersion = Environment.Value("OSVersion")
strTestName = Environment.Value("TestName")
strUserName = Environment.Value("UserName")

How to Close QTP displayed message box with QTP Code?

Sub CMsgbox(strText)
Dim objShell, buttonName
Set objShell= CreateObject("WScript.Shell")
' Display the message box with message and clost itself after 5 seconds
buttonName= objShell.Popup(strText, 5, "Message Box", 0)
End Sub

MessageText= "To know, look at this message box. It will close itself"
' Call the Procedure for message display and close it.
CMsgbox MessageText

What is the Action Template and how to Create it?

Action Template:-
In our test, in every new action, if we want to include one or more statements like Headers (Author name, Creation date, Change log etc...), function calls, etc... We can create an action template(Text file) with these statements. Save it as ActionTemplate.mst in below path in local machine.
Path:- QuickTestInstallation Folder\dat folder.

Note: QTP identifying only the file name ActionTemplate.mst is recognized as an action template.

Wednesday, January 21, 2009

Methods for Retrive Data from DB Query result

Number of Columns in DB Query Results :-
Column count= Fields.Count

Number of in DB Query Results :-
Record/Row count= RecordSet.recordcount

Get the Column value from a particualr Record :-
value= RecordSet.Fields(Index of the Column).Value

How to confirm DB (Database) connection is successfully connected?
Return value= RecordSetObjectName.State
0-- Zero represents for NOT connected successfull
1-- One represents for Successfull connection.

Sometimes Data base columns we have cast for capture values. we can do same with below query.

Select Cast(filed name as nVarchar(3000)) from table name where condition

XML file creation

Set objXML = CreateObject ("Microsoft.XMLDOM")

'Create our root element using the createElement method
Set objXML.documentElement = objXML.createElement("SourceNode")

'Create Element and Node
Set objsrcl = objXML.createElement ("FirstNameAttribute") objXML.documentElement.appendChild objsrcl.cloneNode(true)
Set Node = objXML.documentElement.selectSingleNode("FirstNameAttribute")

' Create Attributes and assign values
Node.setAttribute "FirstNameAttribute", " Value"
Node.setAttribute "Second", "Value"
Node.setAttribute "third", "Value"
Node.setAttribute "Fourth","Value"
Node.setAttribute "Site", "Site"

'Save the file as XML
objxml.save "C:\CreatedXML.XML"

How to Count and close all open Browsers?

' Create description for Browser
Set strBrowser=Description.Create
strBrowser("micclass").value="Browser"
Set strBrowserObject=Desktop.ChildObjects(strBrowser)
' get the Open browsers count
BrowserCnt=strBrowserObject.count

For i=0 to BrowserCnt-1
' Get the open browsers name
BrowserName=strBrowserObject(i).getroproperty("name")
' close the open browser
strBrowserObject(i).Close
Next

How to split a text based on end of line?

Use Split function with "VbCrLf" Constraint, see the below code snippet.
text= enter text, which is having with End of line
Split(Text, VbCrLf)

Monday, January 19, 2009

Get the font Size and Color of the Object

we can get Font size, Font color, Style and Font type with below code:

intFontSize=Browser(“Browsername”).Page(“PageName”).WebElement(“WebElement”).Object.CurrentStyle.FontSize

strFontColour=Browser(“Browsername”).Page(“PageName”).WebElement(“WebElement”).Object.CurrentStyle.Color

strFontStyle=Browser(“Browsername”).Page(“PageName”).WebElement(“WebElement”).Object.CurrentStyle.FontStyle

strFontType=Browser(“Browsername”).Page(“PageName”).WebElement(“WebElement”).Object.CurrentStyle.FontFamily

How can we get ToolTip of the Link?

Browser("BrowserName").Page("PageName").Link("LinkName").FireEvent "onmouseover"

Wait(2)
ToolTipText= Window("nativeclass:=tooltips_class32").GetROProperty("text")