SlideShare uma empresa Scribd logo
1 de 22
Option explicit
Dim comobj, conobj
Set conobj=createobject("ADODB.Connection")
conobj.open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:Documents
and SettingsSai SarvaniDesktopsample.mdb" Set
comobj=createobject ("ADODB.Command")
comobj.activeconnection = conobj
comobj.commandtext = "Insert into emp values ('Appa Rao', 101, 10000)"
comobj.execute
conobj.close
Set comobj = nothing
Set conobj = nothing
How to set multiple records into database table by taking the data from Excel file
Option explicit
Dim comobj,conobj,rcount,i,ename,eno,esal
Set conobj=createobject("ADODB.Connection")
conobj.open "PRovider=Microsoft.jet.oledb.4.0;
data Source = C:Documents and SettingsSai SarvaniDesktopsample.mdb"
Set comobj=createobject("ADODB.Command")
comobj.activeconnection=conobj
datatable.AddSheet ("data")
datatable.ImportSheet "C:Documents and SettingsSai SarvaniDesktop
testdata.xls",1,"data"
rcount=datatable.GetSheet("data").getrowcount For
i=1 to rcount step 1
datatable.SetCurrentRow (i)
ename=datatable.Value (1, "data")
eno=datatable.Value (2, "data")
esal=datatable.Value (3, "data")
comobj.commandtext = "insert into emp values ('"&ename&"', "&eno&", "&esal&")"
comobj.execute
Next conobj.close
Set conobj=Nothing
SetComobj=nothing
How to get data from database table?
Option explicit Dim conobj,rsobj,username,password
Set conobj=createobject("ADODB.connection")
conobj.open "PRovider=Microsoft.jet.oledb.4.0;
data Source = C:Documents and SettingsSai SarvaniDesktopsample.mdb"
Set rsobj=Createobject("ADODB.recordset")
rsobj.open "select * from login", conobj
rsobj.movefirst
While not rsobj.eof
username=rsobj("uid")
password=rsobj("pwd")
SystemUtil.Run "C:Program FilesMercury InteractiveQuickTest
Professionalsamplesflightappflight4a.exe"
Dialog("Login").WinEdit("Agent Name:").Set username
Dialog("Login").WinEdit("Password:").SetSecure crypt.Encrypt (password)
Dialog("Login").WinButton("OK").Click
If window("Flight Reservation").Exist Then
reporter.ReportEvent micPass, "Login success", "Test is Pass" Window("Flight
Reservation").WinMenu("Menu").Select "File;Exit"
else
reporter.ReportEvent micFail, "Login Fail", "Test is fail"
Dialog("Login").Dialog("Flight Reservations").WinButton("OK").Click
Dialog("Login").WinButton("Cancel").Click
End If
rsobj.movenext
Wend
rsobj.close
conobj.close
Set rsobj=nothing
Set Conobj=nothing
QTP- Execute the bat file , dos command from QTP
dim appset app=createobject("wscript.shell")
SystemUtil.run "cmd.exe"
app.sendkeys "cd C:Documents and Settings'<>"
app.sendkeys "~"
app.sendkeys "MyDosFile.bat"
app.sendkeys "~" app.sendkeys "~"
wait(5)
'In bat file you can give and save
Date
echo "hello World"
pause
‘*****************************************************************************
****
QTP/QC - Schedule the testset in QC by VBS
'User must Admin at the machine where he want to run the testset
'This can run manual as well as Automated test suite
' It can be schedule at any partcular future time
' User need not to open the QC
Public Sub RunTestSet(otdc,tsFolderName,tSetName,HostName,runWhere)
Dim TSetFact, tsList
Dim theTestSet
Dim tsTreeMgr
Dim tsFolder
Dim Scheduler
Dim nPath
Dim execStatus
' Get the test set tree manager from the test set factory
'tdc is the global TDConnection object.
Set TSetFact = otdc.TestSetFactory
Set tsTreeMgr = otdc.TestSetTreeManager
' Get the test set folder passed as an argument to the example code
nPath = "Root" & Trim(tsFolderName)
Set tsFolder = tsTreeMgr.NodeByPath(nPath)
If tsFolder Is Nothing Then
err.Raise vbObjectError + 1, "RunTestSet", "Could not find folder " & nPath
End If
' Search for the test set passed as an argument to the example code
Set tsList = tsFolder.FindTestSets(tSetName)
If tsList Is Nothing Then
err.Raise vbObjectError + 1, "RunTestSet", "Could not find test set in the " & nPath
End If
If tsList.Count > 1 Then
MsgBox "FindTestSets found more than one test set: refine search"
Exit Sub
ElseIf tsList.Count < 1 Then
MsgBox "FindTestSets: test set not found"
Exit Sub
End If
Set theTestSet = tsList.Item(1)
Debug.Print theTestSet.ID
'Start the scheduler on the local machine
Set Scheduler = theTestSet.StartExecution(HostName)
'msgbox "pass"
'Set up for the run depending on where the test instances
' are to execute.
Select Case runWhere
Case "RUN_LOCAL"
'Run all tests on the local machine
Scheduler.RunAllLocally = True
Case "RUN_REMOTE"
'Set Scheduler = theTestSet.StartExecution(HostName)
'Run tests on a specified remote machine
Scheduler.TdHostName = HostName
'Scheduler.TdHostName=runWhere
' RunAllLocally must not be set for
' remote invocation of tests.
' Do not do this:
' Scheduler.RunAllLocally = False
Case "RUN_PLANNED_HOST"
'Run on the hosts as planned in the test set
Dim TSTestFact, TestList
Dim tsFilter
Dim TSTst
'Get the test instances from the test set
Set TSTestFact = theTestSet.TSTestFactory
Set tsFilter = TSTestFact.Filter
tsFilter.Filter("TC_CYCLE_ID") = theTestSet.ID
Set TestList = TSTestFact.NewList(tsFilter.Text)
Scheduler.RunAllLocally = False
End Select
'Run the tests
Scheduler.run
Set execStatus = Scheduler.ExecutionStatus
While (RunFinished = False)
execStatus.RefreshExecStatusInfo "all", True
RunFinished = execStatus.Finished
Wend
End Sub
'================================
Const qcHostName = "GiveQChost:8080"
Const qcDomain = "GiveDomain name"
Const qcProject = "GiveProject" 'Please define here the name of the project
Const qcUser = "User ID" 'Please define here the username
Const qcPassword = "Give Password HGBGH%3&42" 'Please define here the password
Dim tdc
Dim qcServer
Dim objArgs
Dim strArg
Dim strTestSet
Dim bRunCode
'======GETTING ARGUMENTS==============
set objArgs = WScript.Arguments
If WScript.Arguments.Count<1>2 Then
WScript.Echo "Remote_Scheduler"
bRunCode = False
Else
For Each strArg in objArgs
WScript.Echo strArg&" is starting…"
strTestSet = strArg
bRunCode = True
Next
End If
'===========================================================
If bRunCode Then
qcServer = "http://" & qcHostName
qcServer = qcServer & "/qcbin"
Set tdc = CreateObject("tdapiole80.tdconnection")
If (tdc Is Nothing) Then
MsgBox "tdc object is empty"
End If
tdc.InitConnectionEx qcServer
tdc.Login qcUser, qcPassword
tdc.Connect qcDomain, qcProject
RunTestSet tdc, "GiveFolder Name of Test Set","GiveTestSet name ","Givemachinename",
"RUN_REMOTE"
'Disconnect from the project
If tdc.Connected Then
tdc.Disconnect
End If
'Log off the server
If tdc.LoggedIn Then
tdc.Logout
End If
'Release the TDConnection object.
tdc.ReleaseConnection
'"Check status (For illustrative purposes.)
Set tdc = Nothing
End IF
‘*****************************************************************************
********************************
QTP/QC - Running bat file from QC
Povide the bat file 'Driverbat.bat' remove ' sign and put bat under folder C:QTP_Resource.
'cd C:QTP_Resource
'DriverScript_QTP
'C:QTP_ResourceUtility2.exe auto some other utility
'Exit
In QC > Create a VAPI-XP test > in test script put the code
Dim objShell
Set objShell = CreateObject("WScript.Shell")
'objShell.Run "CMD.exe"
objShell .Run "%comspec% /k c: & cd C:QTP_Resource Driverbat.bat"
BR>
'objShell.Run "%comspec% /k c: & cd C:QTP_ResourceDriverbat.bat"
BR>
'qtAppWin.sendkeys "~"
‘*****************************************************************************
******************************************************************************
******************************************************************************
*******
'Get all the items from FlyFrom Combobox and set into textfile
Dim objTxt, objFile,Items_Count,i
Set objTxt=CreateObject("Scripting.Filesystemobject")
objTxt.CreateFolder ("D:Flight_Items")
set objFile=objTxt.CreateTextFile("D:Flight_ItemsList_Items.txt")
Items_Count = Window("Flight Reservation").WinComboBox("Fly From:").GetItemsCount()
For i=0 to Items_Count-1 step 1
objFile.WriteLine Window("Flight Reservation").WinComboBox("Fly From:").GetItem(i)
Next
objFile.Close
Set objTxt=Nothing
'*****************************************************************************
***************************************
'How to set data from file into another text file
Dim objTxt,objFile1,objFile2,arr,i,x
Set objTxt=Createobject("Scripting.Filesystemobject")
set objFile1=objTxt.OpenTextFile("D:abc.txt",1)
Set objFile2=objTxt.OpenTextFile("D:abcd.txt",2)
While not objFile1.AtEndOfStream
x=objFile1.ReadLine
arr=split(x," ")
For i=0 to Ubound(arr)
objFile2.WriteLine arr(i)
Next
Wend
objFile1.Close
objFile2.Close
Set objTxt=Nothing
'***************************************************************************
' How to set data from one text file into another text file as peramid(
'1
'12
'123
'1234
'*****************************************************************************
******
'Working with text file
FirstfilePath="D:abc.txt"
SecondfilePath="D:abcd.txt"
Set ObjText = CreateObject("Scripting.FileSystemObject")
Set File1=ObjText.OpenTextFile(FirstfilePath,1)
Set File2=ObjText.OpenTextFile(SecondfilePath,2)
'Getting data from first file path which is in vertical
While not File1.AtEndOfStream
'To get the line
x=File1.ReadLine
s=s&x
File2.WriteLine s
Wend
'*****************************************************************************
********
' How to close all the browsers
Set objDesc=Description.Create
objDesc("micclass").value="Browser"
set objBr=Desktop.ChildObjects(objDesc)
'msgbox objBr.count
For i=0 to objBr.count-1 step 1
objBr(i).close
Next
'***************************************************************************
' How to close all the browsers except our specified browser
Set objDesc=Description.Create
objDesc("micclass").value="Browser"
set objBr=Desktop.ChildObjects(objDesc)
'msgbox objBr.count
For i=0 to objBr.count-1 step 1
BrName=objBr(i).GetRoProperty("name")
If BrName <> "Real Estate Listings, Homes for Sale and Rental Property
Listings – REALTOR.com®" Then
objBr(i).close
End If
Next
'***************************************************************************
' How to delete specified mails from the INBOX
Dim RowCount,i,StrData,objCi
RowCount = Browser("Gmail - Inbox (537) -").Page("Gmail - Inbox (537)
-").Frame("c1ds2cindlqxf2").WebTable("HDFC BANK").RowCount()
msgbox RowCount
For i=1 to RowCount step 1
StrData = Browser("Gmail - Inbox (537) -").Page("Gmail - Inbox (537)
-").Frame("c1ds2cindlqxf2").WebTable("HDFC BANK").GetCellData(i, 3)
If StrData="NageshQTP" Then
set objCi=Browser("Gmail - Inbox (537) -").Page("Gmail - Inbox (537)
-").Frame("c1ds2cindlqxf2").WebTable("HDFC BANK").ChildItem (i,1,"WebCheckBox",0)
objCi.set "ON"
End If
Next
'*****************************************************************************
******************************************************************************
*****************************
'Prepare descriptive programming for login functionality"
Set objDia=Description.Create
objDia.Add "text","Login"
objDia.Add "window id","0"
Set objUid=Description.Create
objUid.Add "attached text","Agent Name:"
Set objPwd=Description.Create
objPwd.Add "attached text","Password:"
Set objBut=Description.Create
objBut.Add "text","OK"
Dialog(objDia).Activate
Dialog(objDia).winedit(objUid).Set "nagesh"
Dialog(objDia).winedit(objPwd).Set "mercury"
Dialog(objDia).winbutton(objBut).Click
'****************************************************
'Prepare descriptive programming for gmail login 2nd method --B
Set objBr= Description.Create
objBr.Add "name","Gmail: Email from Google"
Set objpage= Description.Create
objpage.Add "title", "Gmail: Email from Google"
Set objuid= Description.Create
objuid.Add "name","Email"
Set objpwd=Description.Create
objpwd.Add "name","Passwd"
Set objsgn=Description.Create
objsgn.Add "name","Sign in"
Browser(objBr).page(objpage).webedit(objuid).set "chenna"
Browser(objBr).page(objpage).webedit(objpwd).Setsecure"4cd631e45d907d79a503c02cdc57c2
59721e1112"
Browser(objBr).page(objpage).webbutton(objsgn).click
'***************************************************************
2nd method --A
Set objBr= Description.Create
objBr("name").value="Gmail: Email from Google"
Set objpage= Description.Create
objpage("title").value= "Gmail: Email from Google"
Set objuid= Description.Create
objuid("name").value="Email"
Set objpwd=Description.Create
objpwd("name").Value="Passwd"
Set objsgn=Description.Create
objsgn("name").value="Sign in"
Browser(objBr).page(objpage).webedit(objuid).set "chenna"
Browser(objBr).page(objpage).webedit(objpwd).Setsecure"4cd631e45d907d79a503c02cdc57c2
59721e1112"
Browser(objBr).page(objpage).webbutton(objsgn).click
'***************************************************************
'How to get google search items
Dim x,y,objDev,objShell,objDesc,objColl,i,strName
x=Browser("Google").Page("Google").WebEdit("q").GetROProperty("abs_x")
y=Browser("Google").Page("Google").WebEdit("q").GetROProperty("abs_y")
Set objDev=Createobject("mercury.devicereplay")
objDev.MouseClick x,y,LEFT_MOUSE_BUTTON
Set objShell=Createobject("wscript.shell")
objShell.SendKeys "Testing"
wait(5)
Set objDesc=Description.Create
objDesc("micclass").value="WebElement"
objDesc("name").value="Google Search"
set objColl=Browser("Google").Page("Google").WebTable("quotes").ChildObjects(objDesc)
msgbox objColl.count
For i=0 to objColl.count-1 step 1
objShell.SendKeys "{DOWN}"
strName=objColl(i).getroproperty("innertext")
Reporter.ReportEvent micDone,"Google Search Item "&strName,"Item
captured"
Next
Set objDev=Nothing
Set objShell=Nothing
‘**********************************************************************
How to connect to sql server
Option Explicit
Dim objCon,objCom
Set objCon=Createobject("ADODB.connection")
objCon.Open "Provider=SQLOLEDB.1;Integrated Security=SSPI;Persist Security Info=False;Initial
Catalog=Testdata;Data Source=."
Set objCom=CreateObject("ADODB.command")
objCom.ActiveConnection=objCon
objCom.CommandText="Insert into EmpDetails values('Srinivas',102,1000)"
objCom.Execute
objCon.Close
Set objCom=Nothing
Set objCon=Nothing
‘*************************************************************************
' Verify Login functionality with multiple UID;s and PWd's by passing data from excel
Option explicit
Dim intRowcount,i,strUid,strPwd
datatable.AddSheet("input")
datatable.ImportSheet "D:Login.xls",1,"input"
intRowcount=Datatable.GetSheet("input").GetRowCount
For i=1 to intRowcount step 1
datatable.SetCurrentRow(i)
strUid=Datatable.Value(1,"input")
strPwd=Datatable.Value(2,"input")
systemutil.Run "C:Program FilesHPQuickTest
Professionalsamplesflightappflight4a.exe"
Dialog("Login").Activate
Dialog("Login").WinEdit("Agent Name:").Set strUid
Dialog("Login").WinEdit("Password:").SetSecure crypt.Encrypt(strPwd)
Dialog("Login").WinButton("OK").Click
wait(7)
If Window("Flight Reservation").Exist Then
Reporter.ReportEvent micPass,"Login suc","Test is Pass"
Window("Flight Reservation").WinMenu("Menu").Select
"File;Exit"
Else
Reporter.ReportEvent micFail,"Login Unsuc","Test is Fail"
Dialog("Login").Dialog("Flight
Reservations").WinButton("OK").Click
Dialog("Login").WinButton("Cancel").Click
End if
Next
‘*****************************************************************
Examples on Functions(Web Applications)
‘****************************************************
' Functio Name:Clear_Cookies
'Function Descrition:It is used to clear the cookies
'Authour:=Nagesh
'Created:=09082010
'*****************************************************************************
*********************
Function Clear_Cookies()
Systemutil.Run "iexplore","www.realtor.com"
webutil.DeleteCookies
systemutil.CloseDescendentProcesses
End Function
'*********************************************************************
' Functio Name:Application_Launch
'Function Descrition:It is used to launch the application
'Authour:=Nagesh
'Created:=09082010
'*****************************************************************************
*********************
Function Application_Launch(strUrl)
systemutil.Run "iexplore",strUrl
If Browser("Real Estate Listings,").Page("Real Estate
Listings,").WebElement("FIND HOMES").Exist Then
Reporter.ReportEvent micPass,"Step 1","Application Launched"
Application_Launch="Application Launched"
Else
Reporter.ReportEvent micFail,"Step 1","Application is not Launched"
Application_Launch="Application is not Launched"
End if
End Function
'***********************************************************
' Functio Name:Close_App()
'Function Descrition:It is used to close the application
'Authour:=Nagesh
'Created:=09082010
'*****************************************************************************
*********************
Function Close_App()
If Browser("Real Estate Listings,").Exist(10) Then
Browser("Real Estate Listings,").Close
Close_App="Application Closed"
Else
Close_App="Application not Closed"
End if
End Function
'*************************************************************
' Functio Name:SignUp
'Function Descrition:It is used to register the new user
'Authour:=Nagesh
'Created:=09082010
'*****************************************************************************
*********************
Function SignUp(strEmail,strPwd,strGen,strYOB)
If Browser("Real Estate Listings,").Page("Real Estate Listings,").Link("Sign Up").Exist(10) Then
Browser("Real Estate Listings,").Page("Real Estate Listings,").Link("Sign
Up").Click
Browser("Real Estate Listings,").Page("Real Estate
Listings,").WebEdit("Email").Set strEmail
Browser("Real Estate Listings,").Page("Real Estate
Listings,").WebEdit("Pwd").Set strPwd
Browser("Real Estate Listings,").Page("Real Estate
Listings,").WebEdit("Cpwd").Set strPwd
Browser("Real Estate Listings,").Page("Real Estate
Listings,").WebList("Gender").Select strGen
Browser("Real Estate Listings,").Page("Real Estate
Listings,").WebEdit("YOB").Set strYOB
Browser("Real Estate Listings,").Page("Real Estate Listings,").WebElement("Sign
Up").Click
wait(5)
If Browser("Real Estate Listings,").Page("Real Estate
Listings,").WebElement("innertext:=THANK YOU","index:=1").Exist Then
Browser("Real Estate Listings,").Page("Real Estate
Listings,").WebElement("CLOSE").Click
End if
strMsg=Browser("Real Estate Listings,").Page("Real Estate
Listings,").WebElement("Welcome").GetROProperty("innertext")
arr=split(strMsg,", ")
If instr(strEmail,arr(1))>0 Then
Reporter.ReportEvent micPass,"Step 1","SignedUp Successfull"
SignUp="SignedUp Successfull"
Else
Reporter.ReportEvent micFail,"Step 1","SignedUp Fail"
SignUp="SignedUp Fail"
End If
End If
End Function
'**********************************************************************
' Functio Name:SignOut
'Function Descrition:It is used to Signout from the application
'Authour:=Nagesh
'Created:=09082010
'*****************************************************************************
*********************
Function SignOut()
Browser("Real Estate Listings,").Page("Real Estate Listings,").Link("Sign Out").Click
If Browser("Real Estate Listings,").Page("Real Estate
Listings,").WebElement("Welcome | Sign In | Sign").Exist Then
Reporter.ReportEvent micPass,"Step 1","SignOut SuccessFull"
SignOut="SignOut SuccessFull"
Else
Reporter.ReportEvent micPass,"Step 1","SignOut unSuccessFull"
SignOut="SignOut UnSuccessFull"
End If
End Function
'*************************************************************************
' Functio Name:SignIn
'Function Descrition:It is used to login to the application
'Authour:=Nagesh
'Created:=09082010
'*****************************************************************************
*********************
Function SignIn(strEmail,strPwd)
If Browser("Real Estate Listings,").Page("Real Estate Listings,").Link("Sign
In").Exist Then
Browser("Real Estate Listings,").Page("Real Estate
Listings,").Link("Sign In").Click
Browser("Real Estate Listings,").Page("Real Estate
Listings,").WebEdit("EmailID").Set strEmail
Browser("Real Estate Listings,").Page("Real Estate
Listings,").WebEdit("Password").Set strPwd
Browser("Real Estate Listings,").Page("Real Estate
Listings,").WebElement("Sign In").Click
wait(4)
strMsg=Browser("Real Estate Listings,").Page("Real Estate
Listings,").WebElement("Welcome").GetROProperty("innertext")
arr=Split(strMsg,", ")
If instr(strEmail,arr(1))>0 Then
Reporter.ReportEvent micPass,"Step 1","SignIn
SuccessFull"
SignIn="SignIn SuccessFull"
Else
Reporter.ReportEvent micFail,"Step 1","SignIn
Unsucessfull"
SignIn="SignIn Unsucessfull"
End If
End If
End Function
'************************************************************************

Mais conteúdo relacionado

Mais procurados

Building Real Time Systems on MongoDB Using the Oplog at Stripe
Building Real Time Systems on MongoDB Using the Oplog at StripeBuilding Real Time Systems on MongoDB Using the Oplog at Stripe
Building Real Time Systems on MongoDB Using the Oplog at Stripe
MongoDB
 
Active Record Query Interface (1), Season 2
Active Record Query Interface (1), Season 2Active Record Query Interface (1), Season 2
Active Record Query Interface (1), Season 2
RORLAB
 
Microsoft Ado
Microsoft AdoMicrosoft Ado
Microsoft Ado
oswchavez
 

Mais procurados (19)

ActiveRecord Query Interface (1), Season 1
ActiveRecord Query Interface (1), Season 1ActiveRecord Query Interface (1), Season 1
ActiveRecord Query Interface (1), Season 1
 
H base programming
H base programmingH base programming
H base programming
 
The Ring programming language version 1.4 book - Part 18 of 30
The Ring programming language version 1.4 book - Part 18 of 30The Ring programming language version 1.4 book - Part 18 of 30
The Ring programming language version 1.4 book - Part 18 of 30
 
Stored Procedures and MUMPS for DivConq
 Stored Procedures and  MUMPS for DivConq  Stored Procedures and  MUMPS for DivConq
Stored Procedures and MUMPS for DivConq
 
外部環境への依存をテストする
外部環境への依存をテストする外部環境への依存をテストする
外部環境への依存をテストする
 
Building Real Time Systems on MongoDB Using the Oplog at Stripe
Building Real Time Systems on MongoDB Using the Oplog at StripeBuilding Real Time Systems on MongoDB Using the Oplog at Stripe
Building Real Time Systems on MongoDB Using the Oplog at Stripe
 
Spock and Geb in Action
Spock and Geb in ActionSpock and Geb in Action
Spock and Geb in Action
 
Active Record Query Interface (1), Season 2
Active Record Query Interface (1), Season 2Active Record Query Interface (1), Season 2
Active Record Query Interface (1), Season 2
 
The Ring programming language version 1.8 book - Part 49 of 202
The Ring programming language version 1.8 book - Part 49 of 202The Ring programming language version 1.8 book - Part 49 of 202
The Ring programming language version 1.8 book - Part 49 of 202
 
The Ring programming language version 1.3 book - Part 50 of 88
The Ring programming language version 1.3 book - Part 50 of 88The Ring programming language version 1.3 book - Part 50 of 88
The Ring programming language version 1.3 book - Part 50 of 88
 
The Ring programming language version 1.5.1 book - Part 35 of 180
The Ring programming language version 1.5.1 book - Part 35 of 180The Ring programming language version 1.5.1 book - Part 35 of 180
The Ring programming language version 1.5.1 book - Part 35 of 180
 
The Ring programming language version 1.5.3 book - Part 77 of 184
The Ring programming language version 1.5.3 book - Part 77 of 184The Ring programming language version 1.5.3 book - Part 77 of 184
The Ring programming language version 1.5.3 book - Part 77 of 184
 
Spicy javascript: Create your first Chrome extension for web analytics QA
Spicy javascript: Create your first Chrome extension for web analytics QASpicy javascript: Create your first Chrome extension for web analytics QA
Spicy javascript: Create your first Chrome extension for web analytics QA
 
The Ring programming language version 1.7 book - Part 73 of 196
The Ring programming language version 1.7 book - Part 73 of 196The Ring programming language version 1.7 book - Part 73 of 196
The Ring programming language version 1.7 book - Part 73 of 196
 
The Ring programming language version 1.10 book - Part 94 of 212
The Ring programming language version 1.10 book - Part 94 of 212The Ring programming language version 1.10 book - Part 94 of 212
The Ring programming language version 1.10 book - Part 94 of 212
 
The Ring programming language version 1.8 book - Part 75 of 202
The Ring programming language version 1.8 book - Part 75 of 202The Ring programming language version 1.8 book - Part 75 of 202
The Ring programming language version 1.8 book - Part 75 of 202
 
The Ring programming language version 1.6 book - Part 38 of 189
The Ring programming language version 1.6 book - Part 38 of 189The Ring programming language version 1.6 book - Part 38 of 189
The Ring programming language version 1.6 book - Part 38 of 189
 
Tips and Tricks of Developing .NET Application
Tips and Tricks of Developing .NET ApplicationTips and Tricks of Developing .NET Application
Tips and Tricks of Developing .NET Application
 
Microsoft Ado
Microsoft AdoMicrosoft Ado
Microsoft Ado
 

Destaque

Innovación educativa con recursos abiertos
Innovación educativa con recursos abiertosInnovación educativa con recursos abiertos
Innovación educativa con recursos abiertos
Colegio San Ignacio
 
инвестиционный паспорт города орла
инвестиционный паспорт города орлаинвестиционный паспорт города орла
инвестиционный паспорт города орла
litavrika
 
Sjohnson1 powerpoint 2
Sjohnson1 powerpoint 2Sjohnson1 powerpoint 2
Sjohnson1 powerpoint 2
41142391
 
Jawan kp akir tahun 2004
Jawan  kp akir tahun 2004Jawan  kp akir tahun 2004
Jawan kp akir tahun 2004
Opie Mohamad
 
Family tree
Family tree Family tree
Family tree
35150
 
Sogno barcellona
Sogno barcellonaSogno barcellona
Sogno barcellona
Maike Loes
 
Faculty presentation
Faculty presentationFaculty presentation
Faculty presentation
stoliros
 
What's the opposite of creativity?
What's the opposite of creativity?What's the opposite of creativity?
What's the opposite of creativity?
Puneet Bhatnagar
 
Protocolo captura 2011_eu
Protocolo captura 2011_euProtocolo captura 2011_eu
Protocolo captura 2011_eu
Katalogador
 
Lectionline esaltazione della croce anno a
Lectionline esaltazione della croce anno aLectionline esaltazione della croce anno a
Lectionline esaltazione della croce anno a
Maike Loes
 
Revision lesson 1
Revision lesson 1 Revision lesson 1
Revision lesson 1
stoliros
 
Parti melayu semangat 46
Parti melayu semangat 46Parti melayu semangat 46
Parti melayu semangat 46
Opie Mohamad
 

Destaque (20)

Innovación educativa con recursos abiertos
Innovación educativa con recursos abiertosInnovación educativa con recursos abiertos
Innovación educativa con recursos abiertos
 
инвестиционный паспорт города орла
инвестиционный паспорт города орлаинвестиционный паспорт города орла
инвестиционный паспорт города орла
 
Sjohnson1 powerpoint 2
Sjohnson1 powerpoint 2Sjohnson1 powerpoint 2
Sjohnson1 powerpoint 2
 
Jawan kp akir tahun 2004
Jawan  kp akir tahun 2004Jawan  kp akir tahun 2004
Jawan kp akir tahun 2004
 
Print based media
Print based mediaPrint based media
Print based media
 
Generos cine
Generos cine Generos cine
Generos cine
 
Northern Virginia Regional Stats for September
Northern Virginia Regional Stats for SeptemberNorthern Virginia Regional Stats for September
Northern Virginia Regional Stats for September
 
Aquatic animals 1
Aquatic animals  1Aquatic animals  1
Aquatic animals 1
 
Family tree
Family tree Family tree
Family tree
 
Sogno barcellona
Sogno barcellonaSogno barcellona
Sogno barcellona
 
Faculty presentation
Faculty presentationFaculty presentation
Faculty presentation
 
Load Testing with Yandex.Tank (in russian, PyCon Russia 2014)
Load Testing with Yandex.Tank (in russian, PyCon Russia 2014)Load Testing with Yandex.Tank (in russian, PyCon Russia 2014)
Load Testing with Yandex.Tank (in russian, PyCon Russia 2014)
 
Halloween.Presentacion
Halloween.PresentacionHalloween.Presentacion
Halloween.Presentacion
 
What's the opposite of creativity?
What's the opposite of creativity?What's the opposite of creativity?
What's the opposite of creativity?
 
Protocolo captura 2011_eu
Protocolo captura 2011_euProtocolo captura 2011_eu
Protocolo captura 2011_eu
 
Lectionline esaltazione della croce anno a
Lectionline esaltazione della croce anno aLectionline esaltazione della croce anno a
Lectionline esaltazione della croce anno a
 
Revision lesson 1
Revision lesson 1 Revision lesson 1
Revision lesson 1
 
Pvt ltd co
Pvt ltd coPvt ltd co
Pvt ltd co
 
Parti melayu semangat 46
Parti melayu semangat 46Parti melayu semangat 46
Parti melayu semangat 46
 
What can communication do for me
What can communication do for meWhat can communication do for me
What can communication do for me
 

Semelhante a Adodb Scripts And Some Sample Scripts[1]

NetBeans Plugin Development: JRebel Experience Report
NetBeans Plugin Development: JRebel Experience ReportNetBeans Plugin Development: JRebel Experience Report
NetBeans Plugin Development: JRebel Experience Report
Anton Arhipov
 
Qtp script to connect access database
Qtp script to connect access databaseQtp script to connect access database
Qtp script to connect access database
Ramu Palanki
 
Introduction tomongodb
Introduction tomongodbIntroduction tomongodb
Introduction tomongodb
Lee Theobald
 

Semelhante a Adodb Scripts And Some Sample Scripts[1] (20)

The Ring programming language version 1.5.3 book - Part 54 of 184
The Ring programming language version 1.5.3 book - Part 54 of 184The Ring programming language version 1.5.3 book - Part 54 of 184
The Ring programming language version 1.5.3 book - Part 54 of 184
 
The Ring programming language version 1.10 book - Part 54 of 212
The Ring programming language version 1.10 book - Part 54 of 212The Ring programming language version 1.10 book - Part 54 of 212
The Ring programming language version 1.10 book - Part 54 of 212
 
The Ring programming language version 1.2 book - Part 79 of 84
The Ring programming language version 1.2 book - Part 79 of 84The Ring programming language version 1.2 book - Part 79 of 84
The Ring programming language version 1.2 book - Part 79 of 84
 
Kode vb.net
Kode vb.netKode vb.net
Kode vb.net
 
Kode vb.net
Kode vb.netKode vb.net
Kode vb.net
 
NetBeans Plugin Development: JRebel Experience Report
NetBeans Plugin Development: JRebel Experience ReportNetBeans Plugin Development: JRebel Experience Report
NetBeans Plugin Development: JRebel Experience Report
 
Python database access
Python database accessPython database access
Python database access
 
Everything About PowerShell
Everything About PowerShellEverything About PowerShell
Everything About PowerShell
 
Ensure code quality with vs2012
Ensure code quality with vs2012Ensure code quality with vs2012
Ensure code quality with vs2012
 
The Ring programming language version 1.3 book - Part 30 of 88
The Ring programming language version 1.3 book - Part 30 of 88The Ring programming language version 1.3 book - Part 30 of 88
The Ring programming language version 1.3 book - Part 30 of 88
 
The Ring programming language version 1.9 book - Part 53 of 210
The Ring programming language version 1.9 book - Part 53 of 210The Ring programming language version 1.9 book - Part 53 of 210
The Ring programming language version 1.9 book - Part 53 of 210
 
Qtp script to connect access database
Qtp script to connect access databaseQtp script to connect access database
Qtp script to connect access database
 
2012 JDays Bad Tests Good Tests
2012 JDays Bad Tests Good Tests2012 JDays Bad Tests Good Tests
2012 JDays Bad Tests Good Tests
 
JDBC for CSQL Database
JDBC for CSQL DatabaseJDBC for CSQL Database
JDBC for CSQL Database
 
2013 DevFest Vienna - Bad Tests, Good Tests
2013 DevFest Vienna - Bad Tests, Good Tests2013 DevFest Vienna - Bad Tests, Good Tests
2013 DevFest Vienna - Bad Tests, Good Tests
 
The Ring programming language version 1.10 book - Part 47 of 212
The Ring programming language version 1.10 book - Part 47 of 212The Ring programming language version 1.10 book - Part 47 of 212
The Ring programming language version 1.10 book - Part 47 of 212
 
The hitchhicker’s guide to unit testing
The hitchhicker’s guide to unit testingThe hitchhicker’s guide to unit testing
The hitchhicker’s guide to unit testing
 
Public class form1
Public class form1Public class form1
Public class form1
 
Public class form1
Public class form1Public class form1
Public class form1
 
Introduction tomongodb
Introduction tomongodbIntroduction tomongodb
Introduction tomongodb
 

Adodb Scripts And Some Sample Scripts[1]

  • 1. Option explicit Dim comobj, conobj Set conobj=createobject("ADODB.Connection") conobj.open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:Documents and SettingsSai SarvaniDesktopsample.mdb" Set comobj=createobject ("ADODB.Command") comobj.activeconnection = conobj comobj.commandtext = "Insert into emp values ('Appa Rao', 101, 10000)" comobj.execute conobj.close Set comobj = nothing Set conobj = nothing How to set multiple records into database table by taking the data from Excel file Option explicit Dim comobj,conobj,rcount,i,ename,eno,esal Set conobj=createobject("ADODB.Connection") conobj.open "PRovider=Microsoft.jet.oledb.4.0; data Source = C:Documents and SettingsSai SarvaniDesktopsample.mdb" Set comobj=createobject("ADODB.Command") comobj.activeconnection=conobj datatable.AddSheet ("data") datatable.ImportSheet "C:Documents and SettingsSai SarvaniDesktop testdata.xls",1,"data" rcount=datatable.GetSheet("data").getrowcount For i=1 to rcount step 1
  • 2. datatable.SetCurrentRow (i) ename=datatable.Value (1, "data") eno=datatable.Value (2, "data") esal=datatable.Value (3, "data") comobj.commandtext = "insert into emp values ('"&ename&"', "&eno&", "&esal&")" comobj.execute Next conobj.close Set conobj=Nothing SetComobj=nothing How to get data from database table? Option explicit Dim conobj,rsobj,username,password Set conobj=createobject("ADODB.connection") conobj.open "PRovider=Microsoft.jet.oledb.4.0; data Source = C:Documents and SettingsSai SarvaniDesktopsample.mdb" Set rsobj=Createobject("ADODB.recordset") rsobj.open "select * from login", conobj rsobj.movefirst While not rsobj.eof username=rsobj("uid") password=rsobj("pwd") SystemUtil.Run "C:Program FilesMercury InteractiveQuickTest Professionalsamplesflightappflight4a.exe" Dialog("Login").WinEdit("Agent Name:").Set username Dialog("Login").WinEdit("Password:").SetSecure crypt.Encrypt (password) Dialog("Login").WinButton("OK").Click If window("Flight Reservation").Exist Then reporter.ReportEvent micPass, "Login success", "Test is Pass" Window("Flight
  • 3. Reservation").WinMenu("Menu").Select "File;Exit" else reporter.ReportEvent micFail, "Login Fail", "Test is fail" Dialog("Login").Dialog("Flight Reservations").WinButton("OK").Click Dialog("Login").WinButton("Cancel").Click End If rsobj.movenext Wend rsobj.close conobj.close Set rsobj=nothing Set Conobj=nothing QTP- Execute the bat file , dos command from QTP dim appset app=createobject("wscript.shell") SystemUtil.run "cmd.exe" app.sendkeys "cd C:Documents and Settings'<>" app.sendkeys "~" app.sendkeys "MyDosFile.bat" app.sendkeys "~" app.sendkeys "~" wait(5) 'In bat file you can give and save Date echo "hello World" pause ‘***************************************************************************** **** QTP/QC - Schedule the testset in QC by VBS 'User must Admin at the machine where he want to run the testset 'This can run manual as well as Automated test suite ' It can be schedule at any partcular future time ' User need not to open the QC Public Sub RunTestSet(otdc,tsFolderName,tSetName,HostName,runWhere)
  • 4. Dim TSetFact, tsList Dim theTestSet Dim tsTreeMgr Dim tsFolder Dim Scheduler Dim nPath Dim execStatus ' Get the test set tree manager from the test set factory 'tdc is the global TDConnection object. Set TSetFact = otdc.TestSetFactory Set tsTreeMgr = otdc.TestSetTreeManager ' Get the test set folder passed as an argument to the example code nPath = "Root" & Trim(tsFolderName) Set tsFolder = tsTreeMgr.NodeByPath(nPath) If tsFolder Is Nothing Then err.Raise vbObjectError + 1, "RunTestSet", "Could not find folder " & nPath End If ' Search for the test set passed as an argument to the example code Set tsList = tsFolder.FindTestSets(tSetName) If tsList Is Nothing Then err.Raise vbObjectError + 1, "RunTestSet", "Could not find test set in the " & nPath End If If tsList.Count > 1 Then MsgBox "FindTestSets found more than one test set: refine search" Exit Sub ElseIf tsList.Count < 1 Then MsgBox "FindTestSets: test set not found" Exit Sub End If Set theTestSet = tsList.Item(1) Debug.Print theTestSet.ID 'Start the scheduler on the local machine Set Scheduler = theTestSet.StartExecution(HostName) 'msgbox "pass" 'Set up for the run depending on where the test instances ' are to execute. Select Case runWhere
  • 5. Case "RUN_LOCAL" 'Run all tests on the local machine Scheduler.RunAllLocally = True Case "RUN_REMOTE" 'Set Scheduler = theTestSet.StartExecution(HostName) 'Run tests on a specified remote machine Scheduler.TdHostName = HostName 'Scheduler.TdHostName=runWhere ' RunAllLocally must not be set for ' remote invocation of tests. ' Do not do this: ' Scheduler.RunAllLocally = False Case "RUN_PLANNED_HOST" 'Run on the hosts as planned in the test set Dim TSTestFact, TestList Dim tsFilter Dim TSTst 'Get the test instances from the test set Set TSTestFact = theTestSet.TSTestFactory Set tsFilter = TSTestFact.Filter tsFilter.Filter("TC_CYCLE_ID") = theTestSet.ID Set TestList = TSTestFact.NewList(tsFilter.Text) Scheduler.RunAllLocally = False End Select 'Run the tests Scheduler.run Set execStatus = Scheduler.ExecutionStatus While (RunFinished = False) execStatus.RefreshExecStatusInfo "all", True RunFinished = execStatus.Finished Wend End Sub '================================ Const qcHostName = "GiveQChost:8080" Const qcDomain = "GiveDomain name" Const qcProject = "GiveProject" 'Please define here the name of the project Const qcUser = "User ID" 'Please define here the username Const qcPassword = "Give Password HGBGH%3&42" 'Please define here the password Dim tdc Dim qcServer
  • 6. Dim objArgs Dim strArg Dim strTestSet Dim bRunCode '======GETTING ARGUMENTS============== set objArgs = WScript.Arguments If WScript.Arguments.Count<1>2 Then WScript.Echo "Remote_Scheduler" bRunCode = False Else For Each strArg in objArgs WScript.Echo strArg&" is starting…" strTestSet = strArg bRunCode = True Next End If '=========================================================== If bRunCode Then qcServer = "http://" & qcHostName qcServer = qcServer & "/qcbin" Set tdc = CreateObject("tdapiole80.tdconnection") If (tdc Is Nothing) Then MsgBox "tdc object is empty" End If tdc.InitConnectionEx qcServer tdc.Login qcUser, qcPassword tdc.Connect qcDomain, qcProject RunTestSet tdc, "GiveFolder Name of Test Set","GiveTestSet name ","Givemachinename", "RUN_REMOTE" 'Disconnect from the project If tdc.Connected Then tdc.Disconnect End If 'Log off the server If tdc.LoggedIn Then tdc.Logout End If 'Release the TDConnection object. tdc.ReleaseConnection '"Check status (For illustrative purposes.)
  • 7. Set tdc = Nothing End IF ‘***************************************************************************** ******************************** QTP/QC - Running bat file from QC Povide the bat file 'Driverbat.bat' remove ' sign and put bat under folder C:QTP_Resource. 'cd C:QTP_Resource 'DriverScript_QTP 'C:QTP_ResourceUtility2.exe auto some other utility 'Exit In QC > Create a VAPI-XP test > in test script put the code Dim objShell Set objShell = CreateObject("WScript.Shell") 'objShell.Run "CMD.exe" objShell .Run "%comspec% /k c: & cd C:QTP_Resource Driverbat.bat" BR> 'objShell.Run "%comspec% /k c: & cd C:QTP_ResourceDriverbat.bat" BR> 'qtAppWin.sendkeys "~" ‘***************************************************************************** ****************************************************************************** ****************************************************************************** ******* 'Get all the items from FlyFrom Combobox and set into textfile Dim objTxt, objFile,Items_Count,i Set objTxt=CreateObject("Scripting.Filesystemobject") objTxt.CreateFolder ("D:Flight_Items") set objFile=objTxt.CreateTextFile("D:Flight_ItemsList_Items.txt") Items_Count = Window("Flight Reservation").WinComboBox("Fly From:").GetItemsCount() For i=0 to Items_Count-1 step 1
  • 8. objFile.WriteLine Window("Flight Reservation").WinComboBox("Fly From:").GetItem(i) Next objFile.Close Set objTxt=Nothing '***************************************************************************** *************************************** 'How to set data from file into another text file Dim objTxt,objFile1,objFile2,arr,i,x Set objTxt=Createobject("Scripting.Filesystemobject") set objFile1=objTxt.OpenTextFile("D:abc.txt",1) Set objFile2=objTxt.OpenTextFile("D:abcd.txt",2) While not objFile1.AtEndOfStream x=objFile1.ReadLine arr=split(x," ") For i=0 to Ubound(arr) objFile2.WriteLine arr(i) Next Wend objFile1.Close objFile2.Close Set objTxt=Nothing '***************************************************************************
  • 9. ' How to set data from one text file into another text file as peramid( '1 '12 '123 '1234 '***************************************************************************** ****** 'Working with text file FirstfilePath="D:abc.txt" SecondfilePath="D:abcd.txt" Set ObjText = CreateObject("Scripting.FileSystemObject") Set File1=ObjText.OpenTextFile(FirstfilePath,1) Set File2=ObjText.OpenTextFile(SecondfilePath,2) 'Getting data from first file path which is in vertical While not File1.AtEndOfStream 'To get the line x=File1.ReadLine s=s&x File2.WriteLine s Wend '***************************************************************************** ******** ' How to close all the browsers Set objDesc=Description.Create
  • 10. objDesc("micclass").value="Browser" set objBr=Desktop.ChildObjects(objDesc) 'msgbox objBr.count For i=0 to objBr.count-1 step 1 objBr(i).close Next '*************************************************************************** ' How to close all the browsers except our specified browser Set objDesc=Description.Create objDesc("micclass").value="Browser" set objBr=Desktop.ChildObjects(objDesc) 'msgbox objBr.count For i=0 to objBr.count-1 step 1 BrName=objBr(i).GetRoProperty("name") If BrName <> "Real Estate Listings, Homes for Sale and Rental Property Listings – REALTOR.com®" Then objBr(i).close End If Next '*************************************************************************** ' How to delete specified mails from the INBOX
  • 11. Dim RowCount,i,StrData,objCi RowCount = Browser("Gmail - Inbox (537) -").Page("Gmail - Inbox (537) -").Frame("c1ds2cindlqxf2").WebTable("HDFC BANK").RowCount() msgbox RowCount For i=1 to RowCount step 1 StrData = Browser("Gmail - Inbox (537) -").Page("Gmail - Inbox (537) -").Frame("c1ds2cindlqxf2").WebTable("HDFC BANK").GetCellData(i, 3) If StrData="NageshQTP" Then set objCi=Browser("Gmail - Inbox (537) -").Page("Gmail - Inbox (537) -").Frame("c1ds2cindlqxf2").WebTable("HDFC BANK").ChildItem (i,1,"WebCheckBox",0) objCi.set "ON" End If Next '***************************************************************************** ****************************************************************************** ***************************** 'Prepare descriptive programming for login functionality" Set objDia=Description.Create objDia.Add "text","Login" objDia.Add "window id","0" Set objUid=Description.Create objUid.Add "attached text","Agent Name:" Set objPwd=Description.Create objPwd.Add "attached text","Password:"
  • 12. Set objBut=Description.Create objBut.Add "text","OK" Dialog(objDia).Activate Dialog(objDia).winedit(objUid).Set "nagesh" Dialog(objDia).winedit(objPwd).Set "mercury" Dialog(objDia).winbutton(objBut).Click '**************************************************** 'Prepare descriptive programming for gmail login 2nd method --B Set objBr= Description.Create objBr.Add "name","Gmail: Email from Google" Set objpage= Description.Create objpage.Add "title", "Gmail: Email from Google" Set objuid= Description.Create objuid.Add "name","Email" Set objpwd=Description.Create objpwd.Add "name","Passwd" Set objsgn=Description.Create objsgn.Add "name","Sign in"
  • 13. Browser(objBr).page(objpage).webedit(objuid).set "chenna" Browser(objBr).page(objpage).webedit(objpwd).Setsecure"4cd631e45d907d79a503c02cdc57c2 59721e1112" Browser(objBr).page(objpage).webbutton(objsgn).click '*************************************************************** 2nd method --A Set objBr= Description.Create objBr("name").value="Gmail: Email from Google" Set objpage= Description.Create objpage("title").value= "Gmail: Email from Google" Set objuid= Description.Create objuid("name").value="Email" Set objpwd=Description.Create objpwd("name").Value="Passwd" Set objsgn=Description.Create objsgn("name").value="Sign in"
  • 14. Browser(objBr).page(objpage).webedit(objuid).set "chenna" Browser(objBr).page(objpage).webedit(objpwd).Setsecure"4cd631e45d907d79a503c02cdc57c2 59721e1112" Browser(objBr).page(objpage).webbutton(objsgn).click '*************************************************************** 'How to get google search items Dim x,y,objDev,objShell,objDesc,objColl,i,strName x=Browser("Google").Page("Google").WebEdit("q").GetROProperty("abs_x") y=Browser("Google").Page("Google").WebEdit("q").GetROProperty("abs_y") Set objDev=Createobject("mercury.devicereplay") objDev.MouseClick x,y,LEFT_MOUSE_BUTTON Set objShell=Createobject("wscript.shell") objShell.SendKeys "Testing" wait(5) Set objDesc=Description.Create objDesc("micclass").value="WebElement" objDesc("name").value="Google Search" set objColl=Browser("Google").Page("Google").WebTable("quotes").ChildObjects(objDesc) msgbox objColl.count
  • 15. For i=0 to objColl.count-1 step 1 objShell.SendKeys "{DOWN}" strName=objColl(i).getroproperty("innertext") Reporter.ReportEvent micDone,"Google Search Item "&strName,"Item captured" Next Set objDev=Nothing Set objShell=Nothing ‘********************************************************************** How to connect to sql server Option Explicit Dim objCon,objCom Set objCon=Createobject("ADODB.connection") objCon.Open "Provider=SQLOLEDB.1;Integrated Security=SSPI;Persist Security Info=False;Initial Catalog=Testdata;Data Source=." Set objCom=CreateObject("ADODB.command") objCom.ActiveConnection=objCon objCom.CommandText="Insert into EmpDetails values('Srinivas',102,1000)" objCom.Execute objCon.Close Set objCom=Nothing Set objCon=Nothing
  • 16. ‘************************************************************************* ' Verify Login functionality with multiple UID;s and PWd's by passing data from excel Option explicit Dim intRowcount,i,strUid,strPwd datatable.AddSheet("input") datatable.ImportSheet "D:Login.xls",1,"input" intRowcount=Datatable.GetSheet("input").GetRowCount For i=1 to intRowcount step 1 datatable.SetCurrentRow(i) strUid=Datatable.Value(1,"input") strPwd=Datatable.Value(2,"input") systemutil.Run "C:Program FilesHPQuickTest Professionalsamplesflightappflight4a.exe" Dialog("Login").Activate Dialog("Login").WinEdit("Agent Name:").Set strUid Dialog("Login").WinEdit("Password:").SetSecure crypt.Encrypt(strPwd) Dialog("Login").WinButton("OK").Click wait(7) If Window("Flight Reservation").Exist Then Reporter.ReportEvent micPass,"Login suc","Test is Pass" Window("Flight Reservation").WinMenu("Menu").Select "File;Exit" Else Reporter.ReportEvent micFail,"Login Unsuc","Test is Fail" Dialog("Login").Dialog("Flight Reservations").WinButton("OK").Click Dialog("Login").WinButton("Cancel").Click
  • 17. End if Next ‘***************************************************************** Examples on Functions(Web Applications) ‘**************************************************** ' Functio Name:Clear_Cookies 'Function Descrition:It is used to clear the cookies 'Authour:=Nagesh 'Created:=09082010 '***************************************************************************** ********************* Function Clear_Cookies() Systemutil.Run "iexplore","www.realtor.com" webutil.DeleteCookies systemutil.CloseDescendentProcesses End Function '********************************************************************* ' Functio Name:Application_Launch 'Function Descrition:It is used to launch the application 'Authour:=Nagesh 'Created:=09082010 '***************************************************************************** ********************* Function Application_Launch(strUrl)
  • 18. systemutil.Run "iexplore",strUrl If Browser("Real Estate Listings,").Page("Real Estate Listings,").WebElement("FIND HOMES").Exist Then Reporter.ReportEvent micPass,"Step 1","Application Launched" Application_Launch="Application Launched" Else Reporter.ReportEvent micFail,"Step 1","Application is not Launched" Application_Launch="Application is not Launched" End if End Function '*********************************************************** ' Functio Name:Close_App() 'Function Descrition:It is used to close the application 'Authour:=Nagesh 'Created:=09082010 '***************************************************************************** ********************* Function Close_App() If Browser("Real Estate Listings,").Exist(10) Then Browser("Real Estate Listings,").Close Close_App="Application Closed" Else Close_App="Application not Closed" End if
  • 19. End Function '************************************************************* ' Functio Name:SignUp 'Function Descrition:It is used to register the new user 'Authour:=Nagesh 'Created:=09082010 '***************************************************************************** ********************* Function SignUp(strEmail,strPwd,strGen,strYOB) If Browser("Real Estate Listings,").Page("Real Estate Listings,").Link("Sign Up").Exist(10) Then Browser("Real Estate Listings,").Page("Real Estate Listings,").Link("Sign Up").Click Browser("Real Estate Listings,").Page("Real Estate Listings,").WebEdit("Email").Set strEmail Browser("Real Estate Listings,").Page("Real Estate Listings,").WebEdit("Pwd").Set strPwd Browser("Real Estate Listings,").Page("Real Estate Listings,").WebEdit("Cpwd").Set strPwd Browser("Real Estate Listings,").Page("Real Estate Listings,").WebList("Gender").Select strGen Browser("Real Estate Listings,").Page("Real Estate Listings,").WebEdit("YOB").Set strYOB Browser("Real Estate Listings,").Page("Real Estate Listings,").WebElement("Sign Up").Click
  • 20. wait(5) If Browser("Real Estate Listings,").Page("Real Estate Listings,").WebElement("innertext:=THANK YOU","index:=1").Exist Then Browser("Real Estate Listings,").Page("Real Estate Listings,").WebElement("CLOSE").Click End if strMsg=Browser("Real Estate Listings,").Page("Real Estate Listings,").WebElement("Welcome").GetROProperty("innertext") arr=split(strMsg,", ") If instr(strEmail,arr(1))>0 Then Reporter.ReportEvent micPass,"Step 1","SignedUp Successfull" SignUp="SignedUp Successfull" Else Reporter.ReportEvent micFail,"Step 1","SignedUp Fail" SignUp="SignedUp Fail" End If End If End Function '********************************************************************** ' Functio Name:SignOut 'Function Descrition:It is used to Signout from the application 'Authour:=Nagesh 'Created:=09082010 '***************************************************************************** ********************* Function SignOut()
  • 21. Browser("Real Estate Listings,").Page("Real Estate Listings,").Link("Sign Out").Click If Browser("Real Estate Listings,").Page("Real Estate Listings,").WebElement("Welcome | Sign In | Sign").Exist Then Reporter.ReportEvent micPass,"Step 1","SignOut SuccessFull" SignOut="SignOut SuccessFull" Else Reporter.ReportEvent micPass,"Step 1","SignOut unSuccessFull" SignOut="SignOut UnSuccessFull" End If End Function '************************************************************************* ' Functio Name:SignIn 'Function Descrition:It is used to login to the application 'Authour:=Nagesh 'Created:=09082010 '***************************************************************************** ********************* Function SignIn(strEmail,strPwd) If Browser("Real Estate Listings,").Page("Real Estate Listings,").Link("Sign In").Exist Then Browser("Real Estate Listings,").Page("Real Estate Listings,").Link("Sign In").Click
  • 22. Browser("Real Estate Listings,").Page("Real Estate Listings,").WebEdit("EmailID").Set strEmail Browser("Real Estate Listings,").Page("Real Estate Listings,").WebEdit("Password").Set strPwd Browser("Real Estate Listings,").Page("Real Estate Listings,").WebElement("Sign In").Click wait(4) strMsg=Browser("Real Estate Listings,").Page("Real Estate Listings,").WebElement("Welcome").GetROProperty("innertext") arr=Split(strMsg,", ") If instr(strEmail,arr(1))>0 Then Reporter.ReportEvent micPass,"Step 1","SignIn SuccessFull" SignIn="SignIn SuccessFull" Else Reporter.ReportEvent micFail,"Step 1","SignIn Unsucessfull" SignIn="SignIn Unsucessfull" End If End If End Function '************************************************************************