Friday, June 25, 2010

How to Use Dictionary Object in QTP?

Simple Code example for Dictionary object:-
Dim objDict 'Create a variable
Set objDict = CreateObject("Scripting.Dictionary")
objDict.Add "Name", "SP" 'Add some keys and items
objDict.Add "Address", "Street1"
objDict.Add "City", "Bangalore"
objDict.Add "State","Karnataka"
objDict.Add "Country","India"

For Each I in objDict
msgbox objDict.Item(I)
Next

Please find the infromation in the below.

http://www.learnqtp.com/dictionary-object-qtp-use/

Tuesday, June 22, 2010

Unlock QTP Script Which is Locked in Quality Center

Any script is locked in QC By other user, we can unlock script with below code.

Set QCConnection=QCUtil.QCConnection
Set con=QCConnection.command
con.CommandText="DELETE FROM LOCKS WHERE LK_USER ='QC User ID'" Set recset=con.execute

Thursday, May 27, 2010

Enter values in specified Node in XML file

Enter the data in specified Node in XML file with below code.
Code :-
Set Doc = XMLUtil.CreateXML()
Doc.LoadFile "XmlFilePath"
Set root = doc.GetRootElement()
Set children = root.ChildElements()
For i = 1 to datatable.LocalSheet.GetRowCount
datatable.LocalSheet.SetCurrentRow(i)
Set firstChild = doc.GetRootElement().ChildElementsByPath("Node path through Local sheet").Item(1)
firstChild.setValue "Enter Value"
Next
doc.SaveFile "C:\Test_SaveAs.XML"

Friday, May 7, 2010

Get the Numeric value from a Alpha Numeric String

Get the Numeric value from a string which is containing numeric and string combinations with below code :-

strValue="DNT -1,21,21,123.99 value generated"
ActValue = ""
intStringLength = Len(strValue)
For intPos = 1 TO intStringLength
If IsNumeric(Mid(strValue,intPos,1)) Then
ActValue = ActValue & Mid(strValue,intPos,1)Else
If Mid(strValue,intPos,1) = "." Then
ActValue = ActValue & Mid(strValue,intPos,1) End If
End If
Next

Wednesday, May 5, 2010

Count all Links on Web Page

Can you please get the code from below link.

http://torkan.net/blog/?p=418