Forum Discussion
hi
I am using Testcomplete 7 version.
Pls look in to attachments.
The code tries to read from exel sheet and write it to the appplication.
In application only the FNname and Lname are mandatory, other fields are optional.
But if leave any fields empty in exel file.....the code generates an error.
Pls suggest me in this regard.
the code is as follows.....................
Sub main
'luanching the Dexis software
Call TestedApps.Patient_Administration.Run()
Set patient_Administration = Sys.WaitProcess("Patient Administration", -1)
'Call sub routine "PatientCreation" for Creating New patient
call PatientCreation
Log.message("patient Creation is done successfully")
'Closes the Dexis aplication
Call Aliases.Patient_Administration.MainForm.Close()
end sub
sub PatientCreation
Dim drvDriver 'Declare a Driver to access Exel Sheet
Dim strFname
Dim strMname
Dim strLname
Dim strDob
Dim StrSocSecNum
Dim strSex
dim strStreet1
dim strStreet2
dim strCity
dim strState
dim strZipCode
dim strPhone
'Driver is initialised to point to the Exel File
Set drvDriver=DDT.ExcelDriver(Project.Path+"\Data\PatientData.xlsx","sheet1")
strFname=drvDriver.Value("Fname")
strMname=drvDriver.Value("Mname")
strLname=drvDriver.Value("Lname")
strDob= aqConvert.DateTimeToStr(drvDriver.Value("DOB"))
StrSocSecNum=Trim(drvDriver.Value("SSN"))
strSex=Trim(drvDriver.value("SEX"))
strStreet1=Trim(drvDriver.value("Street1"))
strStreet2=drvDriver.value("Street2")
strCity=Trim(drvDriver.value("City"))
strZipCode=Trim(drvDriver.value("State"))
strState=Trim(drvDriver.value("ZipCode"))
strPhone=Trim(drvDriver.value("Phone"))
'read the excel file till the EOF
Do while not drvDriver.EOF()
Set btnNewPatient = Aliases.Patient_Administration.MainForm.zpanelClient.LocalPatientsControl.zpanelSearch.zbuttonNewPatient
Call btnNewPatient.Click()
set ctlCheckBox=Aliases.Patient_Administration.EditPatientDialog.groupBoxPatient
ctlCheckBox.textBoxFirstName.Click()
ctlCheckBox.textBoxFirstName.wText = strFname 'copy the firstName to application
ctlCheckBox.textBoxMiddleName.Click()
ctlCheckBox.textBoxMiddleName.wText=strMname 'copy the MiddleName to application
ctlCheckBox.textBoxLastName.Click()
ctlCheckBox.textBoxLastName.wText=strLname 'copy the LastName to application
ctlCheckBox.maskedTextBoxDateOfBirth.Click()
ctlCheckBox.maskedTextBoxDateOfBirth.wText=strDob
ctlCheckBox.maskedTextBoxSocialSecurityNumber.Click()
ctlCheckBox. maskedTextBoxSocialSecurityNumber.wText=StrSocSecNum
if strSex="F" then
ctlCheckBox.radioButtonFemale.ClickButton()
Else
ctlCheckBox.radioButtonMale.ClickButton()
end if
ctlCheckBox.WinFormsObject("textBoxStreetAddress1").Click()
ctlCheckBox.WinFormsObject("textBoxStreetAddress1").wText=strStreet1
ctlCheckBox.WinFormsObject("textBoxStreetAddress2").Click()
ctlCheckBox. WinFormsObject("textBoxStreetAddress2").wText=strStreet2
ctlCheckBox.WinFormsObject("textBoxCity").Click()
ctlCheckBox. WinFormsObject("textBoxCity").wText=StrCity
ctlCheckBox.WinFormsObject("maskedTextBoxState").Click()
ctlCheckBox. WinFormsObject("maskedTextBoxState").wText=StrState
ctlCheckBox.WinFormsObject("maskedTextBoxZipCode").Click()
ctlCheckBox. WinFormsObject("maskedTextBoxZipCode").wText=strZipCode
ctlCheckBox.WinFormsObject("maskedTextBoxPhoneNumber").Click()
ctlCheckBox.WinFormsObject("maskedTextBoxPhoneNumber").wText=StrPhone
call drvDriver.Next()' Iterate the Driver to next record in Exel Sheet
Aliases.Patient_Administration.EditPatientDialog.buttonOK.Click() 'Click OK button once patient information is entered
if drvDriver.EOF()then
exit Do
Else
strFname=drvDriver.Value("Fname")
strMname=drvDriver.Value("Mname")
strLname=drvDriver.Value("Lname")
strDob=drvDriver.Value("DOB")
strSocSecNum=drvDriver.value("SSN")
strSex=drvDriver.value("SEX")
strStreet1=drvDriver.value("Street1")
strStreet2=drvDriver.value("Street2")
strCity=drvDriver.value("City")
strZipCode=drvDriver.value("State")
strState=drvDriver.value("ZipCode")
strPhone= drvDriver.value("Phone")
end if
loop
end sub
Sub Test1
Call Aliases.Patient_Administration.EditPatientDialog.groupBoxPatient.comboBoxProvider.ClickItem("Provider, Joe J")
End Sub
The xxel sheet includes................
Fname | Mname | Lname | DOB | SSN | SEX | Street1 | Street2 | City | State | ZipCode | Phone |
ffirst | mfirst | lfirst | 12/12/1987 | 123123123 | M | aa | aaa | bang | kar | 1234 | 1234564569 |
fsecond | Empty | fujkk | 12/12/1659 | 11111111 | M | bb | bbb | gadag | kar | 12423 | 2123645633 |
fthird | mthird | lthird | 1/2/1987 | 222222222 | F | cc | ccc | hub | raj | 14234 | 3265423695 |
ffourth | mfourth | lfourth | 1/5/1985 | 333333333 | F | dd | ddd | mysore | raj | 1545 | 4789563216 |
aaaaa | hhhhh | jkkkll | 6/4/1968 | 444444444 | M | ee | eee | Dharwad | mah | 4565 | 2365198471 |
aaa | mmm | zzz | 6/3/1958 | 555555555 | M | ff | fff | bang | jammu | 1333 | 10236520364 |
Related Content
- 2 years ago
Recent Discussions
- 3 hours ago
- 11 hours ago
Working with Visual Test
Solved2 days ago