Jump to content

Unpredictable results


Recommended Posts

I'm having unpredictable results - rather than post all the code right away (as it's quite lengthy) I've attached an image of the code section in question and an image of the result I'm getting and an image of the result I'm expecting.

As you'll see, box 1 and 2 under Source have the default 'Please select' whereas they should have 'Working Tax Credits' and 'Disability living allowance' in 1 and 2 respectively.

Whilst watching the code run I can see the correct results are being selected but by the time the script finishes executing those boxes have changed back to default.

Here's the site https://www.platform.co.uk/webapp/WEBAPP.EXE?WSYD_EVENT=PW10kkfF

I should mention that if I add in a delay e.g. Sleep(500) then selection remains as expected - but I would rather not do this as it slows the script down.

If $MonthlyUniversalTaxCreditIncomeOne > 0 Then
   $oSelect = _IEGetObjByName($oIE, "AP1AMT1")
   $oSelect.Value = ($MonthlyUniversalTaxCreditIncomeOne * 12)
   $oSelect = _IEGetObjByName($oIE, "OGICMB1A")
   _IEFormElementOptionSelect($oSelect, 8, 1, "byValue")
Else
EndIf

If $MonthlyStateDisabilityIncomeOne > 0 Then
   $oSelect = _IEGetObjByName($oIE, "AP1AMT2")
   $oSelect.Value = ($MonthlyStateDisabilityIncomeOne * 12)
   $oSelect = _IEGetObjByName($oIE, "OGICMB1B")
   _IEFormElementOptionSelect($oSelect, 10, 1, "byValue")
Else
EndIf

Strange result.PNG

Expected result.PNG

Code.PNG

Edited by Dent
Change image for code
Link to comment
Share on other sites

@Dent Very annoying event, but its not unpredictable. :)

Just do the source first and you will be fine, i also add a event fire that you were forgetting.

Local $oSource1 = _IEGetObjByName($oIE, "OGICMB1A")
If Not IsObj($oSource1) Then Exit ConsoleWrite("Error in $oSource1" & @CRLF)
_IEFormElementOptionSelect($oSource1, 8)

Local $oSource1Ammount = _IEGetObjByName($oIE, "AP1AMT1")
If Not IsObj($oSource1Ammount) Then Exit ConsoleWrite("Error in $oSource1Ammount" & @CRLF)
_IEFormElementSetValue($oSource1Ammount, "800")
$oSource1Ammount.fireEvent("OnBlur")

Local $oSource2 = _IEGetObjByName($oIE, "OGICMB1B")
If Not IsObj($oSource2) Then Exit ConsoleWrite("Error in $oSource2" & @CRLF)
_IEFormElementOptionSelect($oSource2, 10)

Local $oSource2Ammount = _IEGetObjByName($oIE, "AP1AMT2")
If Not IsObj($oSource2Ammount) Then Exit ConsoleWrite("Error in $oSource2Ammount" & @CRLF)
_IEFormElementSetValue($oSource2Ammount, "900")
$oSource2Ammount.fireEvent("OnBlur")

Local $oDateOfBirth_DAY = _IEGetObjByName($oIE, "AP1DAY")
If Not IsObj($oDateOfBirth_DAY) Then Exit ConsoleWrite("Error in $oDateOfBirth_DAY" & @CRLF)
_IEFormElementOptionSelect($oDateOfBirth_DAY, 1)

Local $oDateOfBirth_MONTH = _IEGetObjByName($oIE, "AP1MONTH")
If Not IsObj($oDateOfBirth_MONTH) Then Exit ConsoleWrite("Error in $oDateOfBirth_MONTH" & @CRLF)
_IEFormElementOptionSelect($oDateOfBirth_MONTH, 1)

Local $oDateOfBirth_YEAR = _IEGetObjByName($oIE, "AP1YEAR")
If Not IsObj($oDateOfBirth_YEAR) Then Exit ConsoleWrite("Error in $oDateOfBirth_YEAR" & @CRLF)
_IEFormElementOptionSelect($oDateOfBirth_YEAR, 1990)

Local $oEmploymentStatus = _IEGetObjByName($oIE, "EmpSt1")
If Not IsObj($oEmploymentStatus) Then Exit ConsoleWrite("Error in $oEmploymentStatus" & @CRLF)
_IEFormElementOptionSelect($oEmploymentStatus, "O")

Local $oMainIncome = _IEGetObjByName($oIE, "AFFINC1")
If Not IsObj($oMainIncome) Then Exit ConsoleWrite("Error in $oMainIncome" & @CRLF)
_IEFormElementSetValue($oMainIncome, "5000")
$oMainIncome.fireEvent("OnBlur")

Local $oBonus = _IEGetObjByName($oIE, "PW10kkbA")
If Not IsObj($oBonus) Then Exit ConsoleWrite("Error in $oBonus" & @CRLF)
_IEFormElementSetValue($oBonus, "1200")
$oBonus.fireEvent("OnBlur")

Local $oGender = _IEGetObjByName($oIE, "APP1GDR")
If Not IsObj($oGender) Then Exit ConsoleWrite("Error in $oGender" & @CRLF)
_IEFormElementOptionSelect($oGender, "M")

Local $oJointApplication = _IEGetObjById($oIE, "JointAppN")
If Not IsObj($oJointApplication) Then Exit ConsoleWrite("Error in $oJointApplication" & @CRLF)
_IEAction($oJointApplication, "click")

 

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...