Forum Discussion
Hi Savitri,
This depends on a way of how you access the file. How do you do this?- NandeeshOccasional Contributorhi...
i am trying to read from exel file and write it in to an application.
Hi Savitri,
There are different ways of working with Excel from TestComplete. For example:
1. Working with Excel GUI.
2. Working with Excel document using the Data-Driven Testing feature of TestComplete.
3. Working with Excel via ADO.
4. Working with Excel using its COM object.
Which exactly way you use to work with Excel?- NandeeshOccasional ContributorI am Working with Excel document using the Data-Driven Testing feature of TestComplete.
Hi Savitri,
In this case, you do not need to have Excel opened with your sheet. The Excel sheet file is accessed by TestComplete without using the Excel application.- NandeeshOccasional Contributor
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 subsub 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 subSub Test1
Call Aliases.Patient_Administration.EditPatientDialog.groupBoxPatient.comboBoxProvider.ClickItem("Provider, Joe J")
End SubThe 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
Hi Savitri,
The error occurs since your code tries to assign the 'null' value returned by the driver to a text field. You need to convert the value to the string format explicitly.- NandeeshOccasional ContributorHi....
One of the fields in my application includes "masked text box" i,e for date, pincode .
How to read values in to these masked text boxes in testcomplete...?
I am trying to use "TcxMRUEdit.properties".....but getting struck in syntax..... - PakemaContributorBetter - Not use DDT,
First of all, for use THIS technology, We must know what exactly name of sheet.
And what I must do if I need immediately work with Excel without it opened?
Better use native vbs and Excel, and don't use doubtful DDT technology - NandeeshOccasional ContributorCan you please tell me how to read a "masked text box " using TcxMRUEdit.properties.
specially reading DOB in the previous code i have pasted.....
Related Content
- 2 years ago
Recent Discussions
- 34 minutes ago
- 6 hours ago