Wednesday, October 27, 2010

creating a new database using vbscript

Set oConn = CreateObject( "ADOX.Catalog" )



oConn.Create "Provider = Microsoft.Jet.OLEDB.4.0; " & _

"Data Source = new_db.mdb"

how to retreive data from a database

Dim oConn, oRst, oField

Dim sql



set oConn = CreateObject("ADODB.Connection")

oConn.Open "QT_Flight32"

set oRst = CreateObject("ADODB.recordset")

oRst.Open "Select * from Orders", oConn

Do Until oRst.EOF

For each oField in oRst.Fields

Print oField.Name & " = " & oField.Value

Next

Print String( 20, "-" )

oRst.MoveNext

loop



oRst.close

oConn.close

http://www.advancedqtp.com/knowledge-base/qtips/databases-id44/adodb/display-records/

Tuesday, October 26, 2010

automating google earth using QTP

There is good article mentioned in advancedqtp.com. It says that it can be automated and here is the URL
http://www.advancedqtp.com/knowledge-base/articles/environment-techniques-id15/web-id34/automating-google-earth/

Can we test mobile applications in the mobile phone

The question is discussed in several forums here I am giving the URLs of the respective forums.

http://www.jamosolutions.com/documents/meuxqtp.html

http://experitest.com/support/tutorial/how-to/set-up-new-project/connect-an-external-device-e-g-android/ - advancedqtp.com

Friday, October 15, 2010

Exporting a OR file to an XML file

The below code snippet helps to export TSR file to XML file.
Set obj = CreateObject("Mercury.ObjectRepositoryUtil")
obj.ExportToXML "SourceFile", "TargetFile"
Set obj = Nothing

Wednesday, October 6, 2010

Intellisense quick help

http://www.advancedqtp.com/knowledge-base/articles/qtp-tricks4/qtp-hacks/intellisense-and-com/#
---------------------------------------------------------------------------------------
http://www.sqaforums.com/showthreaded.php?Cat=0&Number=408757&page=0&vc=1

Tuesday, October 5, 2010

Adding Scripting.Disctionary object in registry

Accessing a Scripting.Dictionary object as part of your QTP and can get the intellisense

HKEY_CURRENT_USER\Software\Mercury Interactive\QuickTest Professional\MicTest\ReservedObjects\

There you’ll see many of QTP’s internal object. DO NOT MESS WITH THEM.
Next, create a new key, with the name of the reserved object (e.g. Advanced QTP)


Enter the key "folder", and create these values :
ProgID (string) - Holds the COM program ID we want to create (e.g. Scripting.Dictionary)
VisibleMode (dWord) - Holds the value 2. This controls the auto-complete and intellisense appearance.
UIName (string) - The name that will refer to the reserved object. Make sure this is the same as the key name.

http://www.advancedqtp.com/knowledge-base/articles/qtp-tricks/qtp-hacks/reserved-objects-as-an-env-object-replacement/

Refer the above link for more details. Thanks to Yaron for his help in advanceqtp.com

Monday, October 4, 2010

Retrieving data from an excel through Database connection

FileName = "C:\Book1.xls"
SheetName = "Sheet1"
vValue = "Murali"

Set objConnection = CreateObject("ADODB.Connection")
Set objRecordSet = CreateObject("ADODB.Recordset")
objConnection.Open "Provider=Microsoft.Jet.OLEDB.4.0;" & "Data Source=" & FileName & ";" & "Extended Properties=""Excel 8.0;HDR=Yes;"";"
strQuery="update [" & SheetName & "$] Set "
strQuery=strQuery & "Country='" & "',"
strQuery=strQuery & "City='" & "'"
strQuery=strQuery & " where Name ='" & vValue &"'"
msgbox strQuery
objRecordset.Open strQuery , objConnection, 3, 3, 1
'Close
objConnection.Close
Set objRecordSet = Nothing

Associating a library file using QTP object model

Dim qApp
Dim qLibs

Set qApp = CreateObject("QuickTest.Application")
qApp.Launch
qApp.Visible = True

qApp.Open "E:\Test1", False, False ' Open a test

Set qLibs = qtApp.Test.Settings.Resources.Libraries ' Get
the libraries collection object
qLibs.Add "C:\Utilities.vbs", 1 ' Add the library to the
collection

qApp.Test.Save
qApp.Quit
Set qLibs = Nothing
Set qApp = Nothing

Retrieving the current time zone information

Here is the simple code snippet to find out the current time zone

Const HKEY_LOCAL_MACHINE = &H80000002
strComputer = "."
Set oReg=GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & strComputer & "\root\default:StdRegProv")
strKeyPath = "SYSTEM\CurrentControlSet\Control\TimeZoneInformation"
strValueName = "StandardName"
oReg.GetExpandedStringValue HKEY_LOCAL_MACHINE,strKeyPath, strValueName,strValue
Set oReg=Nothing
Msgbox(strValue)