Jump to content

IE automation seems to fail randomly


Recommended Posts

My original intention is to use tfl journey planner programmatically so that I can see if there are any planned delays or diversions when I go to work in the next week or month. This simplified code opens the website and fills in the form, presses "Plan Journey" reads the tables with the information in them and goes back to the previous page in a loop. This usually works. However the code execution stops randomly. At the very end it should close IE (if that doesn't happen you know it failed). When I run it usually it completes a few iterations and fails after.

Could you tell me what causes it to stop?

(Please change the date in the third line so that it shows tommorow's date before you test it. The website doesn't work if the inquiry date or time is in the past.)

It's all code from here: (I don't know how to put it)

#include <ie.au3>  
#include <Array.au3>;Only to display the table
local $numberofRepetitions = 7
local $var
local $tableCells
local $cell
local $interchange
local $StartPoint, $destination, $Jdate, $Jtime
$startPoint = "Marble arch"
$Destination = "London Victoria"
$Jtime = "21:50"
$Jdate = "31/07/2013"
 
 
 
for $maincounter = 1 to $numberofRepetitions step 1
   
$oForm = _IEFormGetObjByName ($oIE, "jp_form")  
$oQuery1 = _IEFormElementGetObjByName ($oForm, "startpoint")  
$oQuery2 = _IEFormElementGetObjByName ($oForm, "endpoint")
$oQuery3 = _IEFormElementGetObjByName ($oForm, "jp-time")  
$oQuery4 = _IEFormElementGetObjByName ($oForm, "datepicker") 
 
 
_IEFormElementSetValue ($oQuery1, $startpoint)
_IEFormElementSetValue ($oQuery2, $destination)
_IEFormElementSetValue ($oQuery3, $jtime)
_IEFormElementSetValue ($oQuery4, $jdate)
 
_IELoadWait($oIE,0) 
$oButtons = _IETagnameGetCollection($oForm, "input")
For $oButton in $oButtons
    If String($oButton.value) = "Plan Journey" Then
_IEAction($oButton, "click")
        ExitLoop
    EndIf
 Next
_IELoadWait($oIE,0)
 
 
 
;~ ;display table contents
for $var = 0 to 0 step 1
$oTable = _IETableGetCollection ($oIE, $var)
 
$aTableData = _IETableWriteToArray ($oTable, True)
$aTableData[1][0]= $Jdate
;_ArrayDisplay($aTableData)
next
_IELoadWait($oIE,0)
 
 
_IEAction($oIE, "back")
_IELoadWait($oIE,0) 
 
next
 
_IEQuit($oIE)
Link to comment
Share on other sites

  • Moderators

Hi, tahilaci, welcome to the forum.

First and foremost, I see no error checking at all. How are you checking to determine where and what causes the script to fail? When it fails, what is the output to the console? Have you looked at _IEErrorHandlerRegister or _IEErrorNotify in the Help file?

As we oft say here - help us help you. We need more than "fails randomly, please tell me why" :)

"Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball

How to get your question answered on this forum!

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

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...