Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Values Populated in Incorrect Fields - Web Form
#1
Greetings,

I have been using a QM macro for over 4 years now successfully.
However, very recently the web form fields are being populated incorrectly.
This is intermittent in nature - part of the time correct entries are passed, while at other times the entries are in the wrong fields.
I checked the HTML codes on the fields to see if there were any changes but found none.

Kindly assist.

Code listed as below and the issue place is highlighted with asterisks and comment:

Macro RO Sales gDN
Code:
Copy      Help
;;--- Recorded 13-Oct-13 6:49:06 PM ----
opt slowkeys 1; opt slowmouse 0; spe 70

ExcelSheet es.Init
ARRAY(str) vin, custType, title, fmName, surname, fullName, mobile, regNum, emailAdd, poBox, place, price, rdate
int w, w1, w2, w3, w4, w5, w6, w11, w12, typeNum, found, titleErrorCheck, w10
Htm e, e1, e2, e3, e4, e5, e6, e7, e8, e9, e10, e11, e12, e13, e14, e15, e16, e17, e18, e19, e20, e21, e22, e50, e52, e23
str custType2, title2, fullName2
Acc a, a12, a3
MES m

int varRep ;;string variable. If need numeric, replace str to int or double.
inp- varRep "Kindly input number of times to repeat this procedure"

DateTime t1 t2
str sStart sEnd sTime

t1.FromComputerTime
sStart=t1.ToStr(8)

;str varDat ;;string variable. If need numeric, replace str to int or double.
;inp- varDat "Kindly advise the date to report on VISTA"

titleErrorCheck=0

rep varRep
,
,;;Initialize critical variables as empty
,vin.redim
,custType.redim
,title.redim
,fmName.redim
,surname.redim
,fullName.redim
,mobile.redim
,regNum.redim
,emailAdd.redim
,poBox.redim
,place.redim
,price.redim

,;str varDate = ""
,
,;inp- varDate "" "gDN Date"
,
,
,w1=act(win("Test " "XLMAIN"))
,'D    ;; Down
,
,;get selected cells in Excel
,es.CellsToArray(vin "sel")
,'T
,es.CellsToArray(custType "sel")
,custType2=custType
,'T
,es.CellsToArray(title "sel")
,title2=title
,'T
,es.CellsToArray(fmName "sel")
,'T
,es.CellsToArray(surname "sel")
,'T
,es.CellsToArray(fullName "sel")
,fullName2=fullName
,'T
,es.CellsToArray(mobile "sel")
,'T
,es.CellsToArray(regNum "sel")
,'T
,es.CellsToArray(poBox "sel")
,'T
,es.CellsToArray(place "sel")
,'T
,es.CellsToArray(price "sel")
,'TT
,es.CellsToArray(rdate "sel")
,'T
,es.CellsToArray(emailAdd "sel")
,
,;opt slowkeys 1
,
,w=wait(0 WV win("Register Vehicle Sale " "IEFrame"))
,act w
,;w2=act(win("Register Vehicle Sale - Windows Internet Explorer" "IEFrame"))
,e=htm("INPUT" "ctl00_cphMain_txtSelectVIN" "" w "0" 6 0x121 50)
,e.SetText(vin)
,e1=htm("INPUT" "ctl00_cphMain_btnVINSearch" "" w "0" 7 0x121 50)

,e1.Click
,wait 3
,
,;Vehicle Sale Date
,;*********************************************ISSUE STARTS FROM HERE ON***********************************************************************
,;************************************************************************DATE CHANGE AUTOMATED HERE********************************************************************
,e2=htm("INPUT" "ctl00_cphMain_txtSaleDate" "" w "0" 27 0x121 50)
,e2.SetText(rdate)
,
,
,;Vehicle Registration Date
,e16=htm("INPUT" "ctl00_cphMain_txtRegDate" "" w "0" 28 0x121 50)
,e16.SetText(rdate)
,;************************************************************************DATE CHANGE AUTOMATED HERE********************************************************************
,0.5
,
,
,;Client Type
,e3=htm("SELECT" "ctl00_cphMain_cboClientType" "" w "0" 1 0x121 50)
,
,typeNum=SelStr(1 custType2 "C" "P" "V")
,
,if typeNum=1
,,e3.CbSelect("Company")
,,wait 4
,,gDNCompany(fullName2)    ;;Separate Function 'gDNCompany' written to complete name filling
,,'T;0.5    
,,goto Mobile
,if typeNum=2
,,e3.CbSelect("Private")
,,wait 4
,if typeNum=3
,,e3.CbSelect("VIP")
,,wait 4
,,
,,
,
,;Title
,wait 1
,
,e5=htm("SELECT" "ctl00_cphMain_cboTitle" "" w "0" 2 0x121 50)
,,e5.CbSelect(title2)
,,err
,,,e5.CbSelect("Other")
,,,wait 4
,,,titleErrorCheck = 1
,
,;wait 2
,if titleErrorCheck = 1
,,e21=htm("INPUT" "ctl00_cphMain_txtOtherTitle" "" w "0" 34 0x121 50)
,,e21.SetText(title2)
,,titleErrorCheck = 0
,else if title2.ucase = "OTHER"
,,e21=htm("INPUT" "ctl00_cphMain_txtOtherTitle" "" w "0" 34 0x121 50)
,,e21.SetText("-")
,
,;First & Middle Name
,e4=htm("INPUT" "ctl00_cphMain_txtFirstName" "" w "0" 36 0x121 50)
,if title2.ucase = "OTHER"
,,e4.SetText(fullName2)
,else
,,e4.SetText(fmName)
,
,;Surname
,e6=htm("INPUT" "ctl00_cphMain_txtSurname" "" w "0" 38 0x121 30)
,if title2.ucase = "OTHER"
,,e6.SetText("-")
,else
,,e6.SetText(surname)
,
,
,;Mobile
,if fullName2="M/s. Al Tayer Motors"
,,e20=htm("INPUT" "ctl00_cphMain_txtTelephoneWork" "" w "0" 44 0x121 50)
,,e20.SetText(mobile)
,,e52=htm("INPUT" "ctl00_cphMain_txtTelephoneMobile" "" w "0" 47 0x121 50)
,,e52.SetText("-")
,else
,,e7=htm("INPUT" "ctl00_cphMain_txtTelephoneMobile" "" w "0" 47 0x121 50)
,,e7.SetText(mobile)
,
,
,
,;Registration Number
,e8=htm("INPUT" "ctl00_cphMain_txtRegNumber" "" w "0" 30 0x121 50)
,e8.SetText(regNum)
,
,;Email Address
,e17=htm("INPUT" "ctl00_cphMain_txtEmail" "" w "0" 33 0x121 3)
,e17.SetText(emailAdd)
,
,;Physical Address
,e9=htm("INPUT" "ctl00_cphMain_txtAddress1" "" w "0" 33 0x121 50)
,e9.SetText("-")
,
,;PO Box
,e10=htm("INPUT" "ctl00_cphMain_txtPOBox" "" w "0" 35 0x121 50)
,e10.SetText(poBox)
,
,;Post/Zip Code
,e11=htm("INPUT" "ctl00_cphMain_txtPostcode" "" w "0" 37 0x121 50)
,e11.SetText("-")
,
,;City
,e12=htm("INPUT" "ctl00_cphMain_txtCity" "" w "0" 39 0x121 50)
,e12.SetText(place)
,
,m.style="OC"
,m.x=100
,m.y=500
,m.timeout=800
,m.default='C'

,;t=mes("Go Ahead?" "Go Ahead?" m) ;;***************************************
,
,;Click Register Sale
,e13=htm("INPUT" "ctl00_cphMain_btnRegister" "" w "0" 50 0x121 50)
,e13.ClickAsync
,
,wait 1
,
,;Click 'OK' on email error message
,w11=wait(1 WV win("Message from webpage" "#32770"))
,err
,,goto defender
,a.Find(w11 "WINDOW" "WARNING: You MUST enter a valid email address!" "class=Static" 0x1005 3 0 "previous previous")
,err
,,goto defender
,wait 0.25
,a.Mouse(1);1
,
,;defender
,;wait 2
,;Click 'OK' on error message - DEFENDER NO OPTIONS
,int w8=wait(1 WV win("Message from webpage" "#32770"))
,err
,,goto pricePage
,Acc a1.Find(w8 "WINDOW" "No Option or Extended warranty not available " "class=Static" 0x1035 0 0 "previous previous")
,err
,,goto pricePage
,wait 0.25
,a1.Mouse(1)
,wait 1 ;;******************
,goto toExcel
,
,
,;pricePage
,wait 2
,;;w4=wait(0 WV win("Client Details " "IEFrame"))
,
,
,w4=wait(5 WV win("https://www.globaldealernetworking.com/" "IEFrame"))
,err
,,w4=wait(5 WV win("Client Details " "IEFrame"))

,
,;wait 2
,;if typeNum=1
,,;Htm e23=htm("INPUT" "_ctl0_cphMain_txtForename" "" w4 "0" 13 0x121 10)
,,;e23.SetText("-")
,,;
,,;Htm e24=htm("INPUT" "_ctl0_cphMain_txtSurname" "" w4 "0" 15 0x121 10)
,,;e24.SetText("-")
,,,
,,
,,
,
,
,int repeatPurchasePrice=0
,;PurchasePrice
,wait 2 ;;*****************
,
,
,e14=htm("INPUT" "_ctl0_cphMain_txtPurchasePrice" "" w4 "0" 46 0x121 15)
,err
,,repeatPurchasePrice=repeatPurchasePrice+1
,,if repeatPurchasePrice<13
,,,goto PurchasePrice
,
,e14.SetText(price)
,wait 0.75 ;;******************
,;;Click Next
,e15=htm("INPUT" "_ctl0_cphMain_btnNext" "" w4 "0" 55 0x121 50)
,e15.Click
,wait 1  ;;*************************
,;wait 5
,found=0
,w3=win("Internet Explorer" "IEFrame")
,e18=0
,rep 7
,,wait 1
,,e50=htm("INPUT" "rbnTrue1" "" w3 "0" 3 0x101 10)
,,if e50 ;;page "Question Time! -*"
,,,found=1
,,,e50.Click
,,,wait 1
,,,e22=htm("INPUT" "btnSubmit" "" w3 "0" 5 0x121 5)
,,,e22.Click
,,,wait 1
,,,e18=htm("INPUT" "btnNext" "" w3 "0" 15 0x101 5)
,,,wait 1
,,,e18.Click
,,,err
,,,,int w9=wait(3 WV win("Question Time! - Internet Explorer" "IEFrame"))
,,,,err
,,,,,w9=wait(3 WV win("https://www.globaldealernetworking.com/ - Question Time! " "IEFrame"))
,,,,,
,,,,clo w9
,,,,goto toExcel
,,,break
,,else
,,,;wait 5
,,,w2=wait(0 WV win("select_product " "IEFrame"))
,,,e18=htm("INPUT" "btnNext" "" w2 "0" 17 0x121 30)
,,,
,,,
,,,
,,,
,,,;wait 3
,,,if e18 ;;page "select_product -*"
,,,,found=2
,,,,e18.Click
,,,,;a3.Mouse(1)
,,,,break
,,,else
,,,,wait 0.5
,,,,continue
,,;if(!found) mes "error"
,
,;wait 30 WT w4 "view_policy_details - Windows Internet Explorer"
,w6=wait(0 WV win("view_policy_details " "IEFrame"))
,;wait 3
,;Click 'OK'
,e19=htm("INPUT" "btnNext" "" w6 "0" 2 0x121 50)
,e19.Click
,
,0.25
,w5=wait(0 WV win("Client Details " "IEFrame"))
,
,clo w5
,
,;toExcel
,;activate excel, change executed record VIN to red colour and save file
,act w1
,'L(#13); 0.12   ;; Left(*10)
,Acc a2.Find(w1 "PAGETAB" "Home" "class=NetUIHWND" 0x1005 10)
,a2.Mouse(1);1
,
,;lef 279 105 w1 1; 1 ;;property page 'Ribbon', grid drop down button 'Font Color'
,;lef 31 157 wait(15 win("" "Net UI Tool Window")) 1 ;;NetUIHWND 'Font Color', list item 'Red'
,
,
,es.Save
,
,wait 1


t2.FromComputerTime
sEnd=t2.ToStr(8)
sTime=TimeSpanToStr(t2-t1 2)

out sStart
out sEnd
out sTime

mes "gDN Report Completed" "Execution Successful"

opt slowkeys 0; opt slowmouse 0; spe -1
;---------------------------------------
Best Regards,
Philip
#2
Did you check whether the arrays have correct values after calling all the es.CellsToArray? Maybe the Tabs in Excel sometimes don't work correctly.
#3
No I haven't checked.
It would be difficult to check as most of the times it works.
So, if it were the tab issue in Excel, is there an alternative or should I use a delay of 1 second between tabs?
Best Regards,
Philip
#4
I would not use Tabs to select Excel cells. Now it seems you use CellsToArray to get 1 cell. With it you can get whole row or whole table.

Macro Macro2937
Code:
Copy      Help
ExcelSheet es.Init

;get range: single row of 16 cells that starts from the selected cell
int c0 r0; es.GetRangeInfo("<sel>" c0 r0)
str strRange=ExcelSheet.ExcelRange(c0 r0 c0+15 r0) ;;like A1:P1
ARRAY(str) row; es.CellsToArray(row strRange)

out strRange
out row[0 0]
out row[1 0]
out row[2 0]
#5
Cool, I will implement per your advise and update this thread soon.
Thanks Gintaras.
Best Regards,
Philip
#6
Yes it works like breeze.
Thanks you Gintaras.
Best Regards,
Philip


Forum Jump:


Users browsing this thread: 1 Guest(s)