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)