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

    • Seminko
      By Seminko
      Strange thing. When I load a page in IE and inspect, the elements are clearly there but when I try to find them using _IEGetObjById or _IETagNameGetCollection or even using JS right in the IE console, the elements can't be found.
      Have you guys even encoutered something similar?
      Site's HTML
      <div id="lastdays"> <div class="radio"> <span class="radio"><input id="lastdays_radio" type="radio" name="rangepanel_group" value="lastdays_radio"></span> </div> <div class="content"> <label for="lastdays_radio">Za posledních</label> <label for="lastdays_radio"> </label> <input name="lastdays_days" type="text" value="1" maxlength="3" id="lastdays_days" class="text days" onclick="document.getElementById('lastdays_radio').checked=true;" onfocus="document.getElementById('lastdays_radio').checked=true;"> <label for="lastdays_radio"> </label> <select name="lastdays_period" id="lastdays_period" class="combo" onclick="document.getElementById('lastdays_radio').checked=true;" onfocus="document.getElementById('lastdays_radio').checked=true;"> <option value="D">dnů</option> <option value="W">týdnů</option> <option selected="selected" value="M">měsíců</option> </select> </div> </div> document.getElementById("lastdays_days"); //returns null in IE  
    • XinYoung
      By XinYoung
      I am in need of your guidance once again. I searched the forums for clicking in span, clicking by class, clicking without an ID or Name, etc., but I am unable to find a solution for my problem.
      I am trying to expand this tree in IE. There is an arrow ( > ) that i need to click, but I can't find a way to do it . Alternatively, I can double-click the text "Servers", but that seems to be even more troublesome. I will have to do this 2-3 more times as the tree expands.
      There appears to be an ID for the tree, simply called "tree", but that isn't working when I send a click to it.

      ;Open an IE session and navigate to pgAdmin. Global $oIE = _IECreate($pgAdmin) ;Maximize the IE window. WinSetState(_IEPropertyGet($oIE, "hwnd"), "", @SW_MAXIMIZE) Sleep(2000) ;Expand the tree $oTree = _IEGetObjById($oIE, "tree") _IEAction($oTree, "click") Any ideas?  
    • XinYoung
      By XinYoung
      Hello all!   I'm stuck at a seemingly simple part of my script. Using IE, I'm filling out a web form that involves clicking a "Browse" button and selecting a file. Once the file explorer dialog opens, however, I am unable to control it.
      I have a string, which is the name of the file I want, and I'm trying to insert it into the 'File name:' text box in the dialog (which already has focus), but it doesn't get inserted. I've tried ClipPut and Send. 

      What's even more concerning is, when I close the dialog, the string is then pasted into the very next window that has focus, which is often SciTE. It's like that Browse's file open dialog halts all processes. Once it's closed, the script continues.
      ;~ Open a IE window and navigate to the login page. Global $oIE = _IECreate($urlBBLogin) _IELoadWait($oIE) ;~ Recognize the form on this page (login input boxes). Local $oForm = _IEFormGetObjByName($oIE, "login") Local $oTextLogin = _IEFormElementGetObjByName($oForm, "user_id") Local $oTextPass = _IEFormElementGetObjByName($oForm, "password") ;~ Enter the Automation user credentials into the form. _IEFormElementSetValue($oTextLogin, $bbUsername) _IEFormElementSetValue($oTextPass, $bbPassword) ;~ Click the Login button. _IEFormSubmit($oForm) _IELoadWait($oIE) ;~ Navigate to the feedfile upload page. _IENavigate($oIE, $urlUpload) _IELoadWait($oIE) ;~ Click the Browse button Local $Browse = _IEGetObjById($oIE, "feedFile_chooseLocalFile") _IEAction($Browse, "Click") Local $Browse = WinWait("Choose File to Upload") ;~ Open the file we created. WinActivate($Browse) Send($finalFile) Has anyone else experienced this problem? Any ideas to get around it? Am I approaching this the wrong way?
      Any support is greatly appreciated.
      Thank you.
    • Drac89
      By Drac89
      How do i pass the IE handle to an active windows authentication prompt when the IE shows it is " waiting " , right now it is nt detecting the windows security prompt
      I used the below to wait for it to load until the 60ms timeout but still it isnt working  :
      #Region ;**** Directives created by AutoIt3Wrapper_GUI ****
      #EndRegion ;**** Directives created by AutoIt3Wrapper_GUI ****
      #include <Constants.au3>
      #include <IE_v1.au3>
      If $CmdLine[0] < 2 Then
         MsgBox($MB_OK, "Usage", "ps_WAN <username> <password>")
         wan($CmdLine[1], $CmdLine[2])
      Func wan($email, $password)
       $oIE = _IECreate()
      $ieo=_IENavigate($oIE, "https://cccc")
       Local $hWnd = WinExists("Windows Security")
      if $hWnd = 0 Then
         MsgBox($MB_OK, "Usage", "timeout")
      ControlFocus("Windows Security", "", "[CLASS:DirectUIHWND]")
      ControlFocus("Windows Security", "", "[CLASS:Edit; INSTANCE:1]")

    • SkysLastChance
      By SkysLastChance
      I am trying to wait for a pop up in IE with the title of "filed". I believe it is in a IE-frame.  I am not having any luck attaching to it. The best thing I have been able to do is find the title using the below code. 
      Is there a way I can just make AutoIt wait until it finds the  "Filed" value from the below code?
      Thank you for any help, I am probably making this harder then it really is. 
      $oIE = _IEAttach("Meditech") $oInputs1 = _IETagNameGetCollection($oIE, "div") For $oInput1 in $oInputs1 If StringStripWS($oInput1.innertext,1) = "Filed" Then $target = $oInput1 ExitLoop Else $target = "NOT FOUND" EndIf Next I have tried different variations of
      _IEAttach("MEDITECH","Filed") WinWaitActive("MEDITECH", "Filed") Here is what the popup looks like.