Friday

QTP - Excel Worksheet Object Model


Worksheet API...

Set xlApp=Createobject("Excel.Application")
set xlWorkBook=xlApp.workbooks.add
set xlWorkSheet=xlWorkBook.WorkSheets.add
'Every where on net it is given .WorkSheet instead of .WorkSheets and failing ... take care

' Action we can perform on Worksheet like ...Few this you we can do
xlWorkSheet.Range("A1:B10").interior.colorindex = 34 'Color
outputWkbook.SaveAs testData,,pwd,writeresPwd 'Save
outputWkbook.Close

'Used Range and FInd

With objSheet.UsedRange ‘ select the used range in particular sheet
Set c = .Find (“nn”)’ data to find
For each c in objSheet.UsedRange’ Loop through the used range
If c=”nn” then’ compare with the expected data
c.Interior.ColorIndex = 40′ make the gary color if it finds the data
End If
Set c = .FindNext(c)’ next search

'Copy
objWorkbook1.Worksheets(“Sheet1″).UsedRange.Copy

'Counting
rowsCount=xlWorkSheet.Evaluate("COUNTA(A:A)") 'Will count the # of rows which have non blank value in the column A
colsCount=xlWorkSheet.Evaluate("COUNTA(1:1)") 'Will count the # of non blank columns in 1st row



Worksheets (Worksheet)
Names (Name)
Range
Areas
Borders (Border)
Errors
Error
Font
Interior
Characters
Font
Name
Style
Borders (Border)
Font
Interior
FormatConditions (FormatCondition)
Hyperlinks (Hyperlink)
Validation
Comment
Phonetics (Phonetic)
Shapes (Shape)right arrow
SmartTags
SmartTag
CustomProperties
CustomProperty
SmartTagActions
SmartTagAction
Protection
AllowEditRanges
AllowEditRange
UserAccessList
UserAccess

Comments (Comment)
CustomProperties
CustomProperty
HPageBreaks (HPageBreak)
VPageBreaks (VPageBreak)
Hyperlinks (Hyperlink)
Scenarios (Scenario)
OLEObjects (OLEObject)
Outline
PageSetup
Graphic
QueryTables (QueryTable)
Parameters (Parameter)
PivotTables (PivotTable)
CalculatedFields
CalculatedMembers
CalculatedMember
CubeFields
CubeField
TreeviewControl
PivotCache
PivotFields
PivotFormulas (PivotFormula)
PivotItems (PivotItem)
CubeFields (CubeField)
OLEObjects (OLEObject)
ChartObjects (ChartObject)
Chartright arrow
PivotLayout
AutoFilter
Filters (Filter)
Tab

Monday

QTP - Setting.WebPackage("ReplayType") = 2

reference:
http://www.advancedqtp.com/forums/index.php/topic,584.0.html

Try to run with mouse events, instead of browser events.
Code
GeSHi (qtp):
Setting.WebPackage("ReplayType") = 2 'Mouse events (browser events = 1)


Created by GeSHI 1.0.7.20

I would like to elaborate on Meir's answer, by default QTP communicates with browser objects via DOM events this means that:
Browser().Page().WebElement().Click
Is equivalent to:
Browser().Page().WebElement().Object.Click

If the web application listens to other events they will not be produced. When using device replay QTP physically moves the mouse cursor and simulates a click so it's much closer emulating a user action. I would recommend localizing this change to a function library.
Code
GeSHi (qtp):
Public Function DeviceClick(test_object)

replayType =Setting.WebPackage("ReplayType")' save old state

Setting.WebPackage("ReplayType") = 2

test_object.Click

Setting.WebPackage("ReplayType") = replayType

End Function

RegisterUserFunc "WebElement", "DeviceClick", "DeviceClick"


Created by GeSHI 1.0.7.20

Then you can choose whether to use Click or DeviceClick.

QTP - Register Global Dictionary in REGISTRY

Ref: SQAforums
For memory saving dictionary object you can save in registory like the following options


When you want to share data between different actions in a test, dictionary object can be used. To do this you should create a reserved test object for the Dictionary object. Here is a process to set up a reserved dictionary object. [Source]

1.Open Window’s registry by opening a Run window and entering regedit.
2.Navigate to HKEY_CURRENT_USER\Software\Mercury Interactive\QuickTest Professional\MicTest\ReservedObjects.
3.Create a new key (folder) named GlobalDictionary by right-clicking on the ReservedObjects key and selecting New -> Key.
4.Under the new key, create a String value named ProgID by right-clicking on GlobalDictionary and selecting New -> String Value.
5.Assign “Scripting.Dictionary” to the new ProgID string value by right-clicking on ProgID and selecting “Modify.”
6.If QTP window is already open you need to close and restart it.
7.Now to check whether dictionary object was installed successfully in registry, simple write GlobalDictionary. (don’t forget the dot) and you should see a drop-down containing all methods and properties associated with dictionary object