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")

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

Strange result.PNG

Expected result.PNG


Edited by Dent
Change image for code

Share this post

Link to post
Share on other sites

Please post the code that reproduces that effect, dont need to be everything, just a sample that exemplifies your problem. And avoid to put the code as a image, is much easier to copy and modify than write everything. :)


Share this post

Link to post
Share on other sites

Ok done :)

Hmmm. Just tried running the code again multiple times and it seems to be working every time now? Very strange.

Edited by Dent

Share this post

Link to post
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")

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")

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")

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

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")


  • Like 1

Share this post

Link to post
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

  • Similar Content

    • SkysLastChance
      By SkysLastChance
      I was wondering how I read data inside of a iframe. I would like to be able to click something inside a iframe. However, I can't even find the tag. 
      The id and name change all the time so I can't use those. 
      The code highlighted in blue is what I am trying to click. (second picture)
      Here is what I have tried.
      $target = "" $tags = $oIE.document.GetElementsByTagName("div") For $tag in $tags $class_value = $tag.GetAttribute("class") If string($class_value) = "s_92 altstyle s_93 s_94" Then $target = $tag ConsoleWrite("Tag Found " & $target.outerText&@CRLF) ExitLoop EndIf Next  


    • SkysLastChance
      By SkysLastChance
      WinActivate("MEDITECH - Internet Explorer") Sleep (500) $oIE = _IEAttach("MEDITECH") $oDiv1 = _IEGetObjById($oIE, "sysmenu-searchbarbutton") _IEAction($oDiv1, "click") I am just trying to click the little magnifying glass, next to the gear button with no luck. I was hoping someone might have an idea why this is not working?

    • SkysLastChance
      By SkysLastChance
      I am trying to type a name in patient summary search box. How should I go about doing this. I am clearly not doing it right. (Attached Picture of HTML code.)
      This is what I have tried. I assume this is not working because it is not a form? 
      WinActivate("MEDITECH - Internet Explorer")       Sleep (500)    $oIE = _IEAttach("MEDITECH")    $oForm = _IEFormGetObjByName($oIE, "systemMenu")    $oText = _IEFormElementGetObjByName($oForm, "sysmenu-searchbarinput") _IEFormElementSetValue($oText, "Hey! This works!")
    • seryth
      By seryth
      I have a script that opens some Excel books that  are stored in SharePoint .  Without getting to much into detail as its a very long story I have to open Internet Explorer to the SP site in order for all of this crap to work. 
      Anyway I have a bit of code in my script that i found via google-fu
      $ieList = ProcessList("iexplore.exe") If IsArray($ieList) Then For $I = 1 To Ubound($ieList) -1 ProcessWaitClose($ieList[$I][1]) Next EndIf Exit Now on Windows 7 this bit works great.  On Windows Server 2012 R2 where this things runs is another story.  I need to be able to force close all instances of Internet explorer that are running as part of my code. 
      Any help is appreciated. 
    • aiter
      By aiter
      Just want to report a warning I get when using IE udf and running from F5 in scite

      -> IE.au3 T3.0-2 Warning from function internal function __IEIsObjType, Cannot register internal error handler, cannot trap COM errors (Use _IEErrorHandlerRegister() to register a user error handler)
      When I look at IE.au3 I see a comment that this function has been removed as there are no more fatal errors.

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.