Sign in to follow this  
Followers 0
tahilaci

IE automation seems to fail randomly

3 posts in this topic

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)

Share this post


Link to post
Share on other sites



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


√-1 2^3 ∑ π, and it was delicious!

Share this post


Link to post
Share on other sites

I didn't know how to do error checking, because I'm new to Autoit. I will have a look at it. 

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
Sign in to follow this  
Followers 0