Sub Test1
End Sub
'// Picking random value from available records in grid
Sub Test2
Dim cpd
Dim ultraGrid
Dim r
dim v(5)
Set cpd = Aliases.CPD
Set ultraGrid = cpd.frmCPDMain.MdiClient.frmPerson.ctrlChildView.ugChild
'finding a random row in grid
r=Random(0,ultraGrid.Rows.Count-1)
v(0)= ultragrid.wValue(r,"Child ID")
v(1)= ultragrid.wValue(r,"UNHCR Id")
v(2)= ultragrid.wValue(r,"ICRC Id")
Call ultraGrid.ClickCellXY(0, "Status", 37, 9)
Call ultraGrid.ClickCellXY(0, 1, 65, 6)
cpd.frmChild_CaseData.Close
End Sub
function Random(min,max)
Randomize()
Random =Int ((max-min+1)*rnd+min)
end Function
Sub Test3
Dim cpd
Dim frmLogin
Dim textBox
dim textBox_fn
Dim frmChangePassword
Dim tabControl
Dim tabPage
Dim frmCPDMain
Dim frmPerson
dim v(5)
'Call Aliases.Explorer.wndShell_TrayWnd.ReBarWindow32.MSTaskSwWClass.ToolbarWindow32.CheckItem("CPD", True, False)
'Call TestedApps.CPD.Run(1, True)
'TestedApps.CPD.Run()
TestedApps.CPD2.Run()
Set cpd = Aliases.CPD
Set ultraGrid = cpd.frmCPDMain.MdiClient.frmPerson.ctrlChildView.ugChild
Set frmLogin = cpd.frmLogin
Set textBox = frmLogin.txtUserName
textBox.wText = "admin"
Call textBox.Keys("[Tab]")
Set textBox = frmLogin.txtPassword
textBox.wText = "admin"
Call textBox.Keys("[Tab]")
Call frmLogin.btnOK.Keys("[Enter]")
' Set frmChangePassword = cpd.frmChangePassword
' Set tabControl = frmChangePassword.tabControl1
' Call tabControl.ClickTab("User")
' Set tabPage = tabControl.tpUser
' Set textBox = tabPage.txtOldPassword
' Call textBox.Click(40, 12)
' textBox.wText = "admin"
' Call textBox.Keys("[Tab]")
' Set textBox = tabPage.txtNewPassword
' textBox.wText = "admin"
' Call textBox.Keys("[Tab]")
' Set textBox = tabPage.txtConfirmPassword
' textBox.wText = "admin"
' Call textBox.Keys("[Tab]")
' Call frmChangePassword.btnSave.Keys("[Enter]")
' Call cpd.dlgInterAgencyChildProtectionDatabase.btnOK.Keys("[Enter]")
Set frmCPDMain = cpd.frmCPDMain
Call frmCPDMain.StripMainMenu.Click("Children")
Set frmPerson = frmCPDMain.MdiClient.frmPerson
Call frmPerson.toolStripChild.ClickItem("Search")
Set textBox = frmPerson.ctrlChildView.pnlSearch.splitContainer1.SplitterPanel.grpBoxChild.txtPersonId
Call textBox.Click(93, 10)
set texBox_fn = frmPerson.ctrlChildView.pnlSearch.splitContainer1.SplitterPanel.grpBoxChild.txtChildFName
set texBox_mn = frmPerson.ctrlChildView.pnlSearch.splitContainer1.SplitterPanel.grpBoxChild.txtChildMName
set texBox_ln = frmPerson.ctrlChildView.pnlSearch.splitContainer1.SplitterPanel.grpBoxChild.txtChildLName
r=Random(0,ultraGrid.Rows.Count-1)
v(0)= CStr(ultragrid.wValue(r,"Child ID"))
textBox.wText = Trim(CStr(v(0)))
frmPerson.ctrlChildView.pnlSearch.btnSearch.ClickButton
flag = search_results(v(0),ultragrid,"Child ID")
if flag= 1 Then
Log.Message("Correct Search Results | Child ID ")
Else
Log.Message( "Incorrect Search Results | Child ID")
End If
'Clear Child id textbox
textBox.wText = ""
set texBox_fn = frmPerson.ctrlChildView.pnlSearch.splitContainer1.SplitterPanel.grpBoxChild.txtChildFName
call textBox_fn.click(93,10)
frmPerson.ctrlChildView.pnlSearch.btnSearch.ClickButton
v(1)= ultragrid.wValue(r,"First Name")
While IsNull(v(1))
r=Random(0,ultraGrid.Rows.Count-1)
v(1)= ultragrid.wValue(r,"First Name")
Wend
textBox_fn.wText = Trim(CStr(v(1)))
frmPerson.ctrlChildView.pnlSearch.btnSearch.ClickButton
flag = search_results(v(0),ultragrid,"First Name")
if flag= 1 Then
Log.Message("Correct Search Results | First Name ")
Else
Log.Message( "Incorrect Search Results | First Name")
End If
v(2)= ultragrid.wValue(r,"Middle Name")
v(3)= ultragrid.wValue(r,"Last Name")
End Sub
function search_results(p_value, grid,colid)
row = Null
row1=grid.rows.count
for row = 0 to row1
if Trim(CStr(grid.wValue(row,colid))) = CStr(p_value) Then
search_results = 1
Else
search_results = 0
exit For
end If
'MsgBox(grid.wValue(row,colid))
Next
End Function
Sub Test4
Dim panel
Dim textBox
Set panel = Aliases.CPD.frmCPDMain.MdiClient.frmPerson.ctrlChildView.pnlSearch
Set textBox = panel.splitContainer1.SplitterPanel.grpBoxChild.txtPersonId
Call textBox.Click(94, 10)
textBox.wText = "QA-ED-214"
panel.btnSearch.ClickButton
End Sub
Sub Test5
Dim groupBox
Set groupBox = Aliases.CPD.frmCPDMain.MdiClient.frmPerson.ctrlChildView.pnlSearch.splitContainer1.SplitterPanel.grpBoxChild
Call groupBox.txtChildFName.Click(60, 8)
Call groupBox.txtChildMName.Click(57, 9)
Call groupBox.txtChildLName.Click(53, 6)
End Sub
Friday, October 30, 2009
Thursday, October 29, 2009
TestComplete: DataBase Connection
// Sample Code to Connect to database in Test Complete
Set AConnection = ADO.CreateADOConnection
' Specify the connection string
AConnection.ConnectionString = "Provider=SQLOLEDB.1;Integrated Security=SSPI;Persist Security Info=False;Initial Catalog=master;Data Source=DG18\SQLEXPRESS"
' Suppress the login dialog box
AConnection.LoginPrompt = False
AConnection.Open
' Execute a simple query
Set RecSet = AConnection.Execute_("SELECT * FROM holding")
' Iterate through query results and insert data into the test log
RecSet.MoveFirst
While Not RecSet.EOF
Log.Message RecSet.Fields("Script").Value
RecSet.MoveNext
Wend
AConnection.Close
Set AConnection = ADO.CreateADOConnection
' Specify the connection string
AConnection.ConnectionString = "Provider=SQLOLEDB.1;Integrated Security=SSPI;Persist Security Info=False;Initial Catalog=master;Data Source=DG18\SQLEXPRESS"
' Suppress the login dialog box
AConnection.LoginPrompt = False
AConnection.Open
' Execute a simple query
Set RecSet = AConnection.Execute_("SELECT * FROM holding")
' Iterate through query results and insert data into the test log
RecSet.MoveFirst
While Not RecSet.EOF
Log.Message RecSet.Fields("Script").Value
RecSet.MoveNext
Wend
AConnection.Close
Thursday, October 22, 2009
Stock application
Sub Test2
Dim moneyhoney
dim efile
dim s(2)
dim p
dim q
set efile = DDT.ExcelDriver("C:\Documents and Settings\nsharma\My Documents\Test Complete\test1.xls","Sheet3")
While Not efile.EOF()
s(0)=efile.Value("Script")
s(1)=efile.Value("Price")
s(2)=efile.Value("Qty")
Set form1 = Aliases.moneyhoney.Form1
Call form1.comboBox1.ClickItem("Buy")
Set textBox = form1.textBox1
Call textBox.Click(51, 11)
textBox.wText = s(0)
Set textBox = form1.textBox3
Call textBox.Click(52, 9)
textBox.wText = s(1)
Set textBox = form1.textBox2
Call textBox.Click(33, 8)
textBox.wText = s(2)
Call form1.textBox4.Click(42, 9)
form1.button1.ClickButton
Call form1.StripMainMenu.Click("Held|Holdings")
set holding=Aliases.moneyhoney.holding
'Call form1.holding.dataGridView1.ClickCell(1, "qty")
row=holding.dataGridView1.RowCount-2
col=holding.dataGridView1.ColumnCount-2
temp= CStr(holding.dataGridView1.wValue(row,1))
if StrComp(CStr(s(0)),temp,1) then
Log.Message("Pass"+temp)
Else
Log.Message("Fail"+temp)
end if
if s(1)= holding.dataGridView1.wValue(row,2) then
Log.Message("Pass"+CStr(holding.dataGridView1.wValue(row,2)))
Else
Log.Message("Fail"+CStr(holding.dataGridView1.wValue(row,2)))
end if
if s(2)= holding.dataGridView1.wValue(row,3) then
Log.Message("Pass"+CStr(holding.dataGridView1.wValue(row,3)))
Else
Log.Message("Fail"+CStr(holding.dataGridView1.wValue(row,3)))
end if
Call Aliases.moneyhoney.holding.Close(1000)
efile.Next
Wend
End Sub
Dim moneyhoney
dim efile
dim s(2)
dim p
dim q
set efile = DDT.ExcelDriver("C:\Documents and Settings\nsharma\My Documents\Test Complete\test1.xls","Sheet3")
While Not efile.EOF()
s(0)=efile.Value("Script")
s(1)=efile.Value("Price")
s(2)=efile.Value("Qty")
Set form1 = Aliases.moneyhoney.Form1
Call form1.comboBox1.ClickItem("Buy")
Set textBox = form1.textBox1
Call textBox.Click(51, 11)
textBox.wText = s(0)
Set textBox = form1.textBox3
Call textBox.Click(52, 9)
textBox.wText = s(1)
Set textBox = form1.textBox2
Call textBox.Click(33, 8)
textBox.wText = s(2)
Call form1.textBox4.Click(42, 9)
form1.button1.ClickButton
Call form1.StripMainMenu.Click("Held|Holdings")
set holding=Aliases.moneyhoney.holding
'Call form1.holding.dataGridView1.ClickCell(1, "qty")
row=holding.dataGridView1.RowCount-2
col=holding.dataGridView1.ColumnCount-2
temp= CStr(holding.dataGridView1.wValue(row,1))
if StrComp(CStr(s(0)),temp,1) then
Log.Message("Pass"+temp)
Else
Log.Message("Fail"+temp)
end if
if s(1)= holding.dataGridView1.wValue(row,2) then
Log.Message("Pass"+CStr(holding.dataGridView1.wValue(row,2)))
Else
Log.Message("Fail"+CStr(holding.dataGridView1.wValue(row,2)))
end if
if s(2)= holding.dataGridView1.wValue(row,3) then
Log.Message("Pass"+CStr(holding.dataGridView1.wValue(row,3)))
Else
Log.Message("Fail"+CStr(holding.dataGridView1.wValue(row,3)))
end if
Call Aliases.moneyhoney.holding.Close(1000)
efile.Next
Wend
End Sub
Wednesday, October 21, 2009
Test Complete 7
Following code Picks Username, Password and Message from an excel file and check it on application CPD:
---------------------------------
Sub Test2
dim efile
dim user
dim pwd
Dim cpd
Dim frmLogin
Dim textBox
Dim msg
dim label
set efile = DDT.ExcelDriver("C:\Documents and Settings\nsharma\My Documents\Test Complete\test1.xls","Sheet2")
'Call Aliases.Explorer.wndCPD.SHELLDLL_DefView.DUIViewWndClassName.DirectUIHWND.CtrlNotifySink.FolderView.Click(82, 129)
Call TestedApps.CPD.Run(1, True)
Set cpd = Aliases.CPD
Set frmLogin = cpd.frmLogin
Set textBox = frmLogin.txtUserName
While Not efile.EOF()
user=efile.Value("user")
pwd=efile.Value("pwd")
msg=efile.Value("msg")
textBox.wText = user
Call textBox.Keys("[Tab]")
frmLogin.txtPassword.wText = pwd
frmLogin.btnOK.ClickButton
label= Aliases.CPD.dlgInterAgencyChildProtectionDatabase.child(2).wndcaption
if label=msg then
efile.Value("Result") = "Pass"
Else
set efile.Value("Result") = "Fail"
End If
cpd.dlgInterAgencyChildProtectionDatabase.btnOK.ClickButton
efile.Next
Wend
' frmLogin.btnCancel.ClickButton
End Sub
-------------------------------------------
---------------------------------
Sub Test2
dim efile
dim user
dim pwd
Dim cpd
Dim frmLogin
Dim textBox
Dim msg
dim label
set efile = DDT.ExcelDriver("C:\Documents and Settings\nsharma\My Documents\Test Complete\test1.xls","Sheet2")
'Call Aliases.Explorer.wndCPD.SHELLDLL_DefView.DUIViewWndClassName.DirectUIHWND.CtrlNotifySink.FolderView.Click(82, 129)
Call TestedApps.CPD.Run(1, True)
Set cpd = Aliases.CPD
Set frmLogin = cpd.frmLogin
Set textBox = frmLogin.txtUserName
While Not efile.EOF()
user=efile.Value("user")
pwd=efile.Value("pwd")
msg=efile.Value("msg")
textBox.wText = user
Call textBox.Keys("[Tab]")
frmLogin.txtPassword.wText = pwd
frmLogin.btnOK.ClickButton
label= Aliases.CPD.dlgInterAgencyChildProtectionDatabase.child(2).wndcaption
if label=msg then
efile.Value("Result") = "Pass"
Else
set efile.Value("Result") = "Fail"
End If
cpd.dlgInterAgencyChildProtectionDatabase.btnOK.ClickButton
efile.Next
Wend
' frmLogin.btnCancel.ClickButton
End Sub
-------------------------------------------
Subscribe to:
Posts (Atom)