Sign in to follow this  
Followers 0
RLeatherman

Problems with IE.au3 and IETableWriteToArray()

3 posts in this topic

Hello everyone...

I'm trying to create a script that opens a browser window, logs an administrator in, then runs a query. The query is to bring back a listing of accounts, which I want to capture and write to a file for later processing.

The following script works MOST of the time there are <50 records in the dataset:

CODE
NOTE: $PX_User and $PX_Pass defined earlier....

#include <IE.au3>

#include <Array.au3>

$acct=InputBox("Get Accts", "Enter Account Search String")

; Include UDF for Internet Explorer functions

$sUrl = "http://payxpressadmin.twcable.com/user/UserSearch.aspx"

;Open a Browser Window to PayXpress

$oIE = _IECreate($sUrl)

;Initial Login, so get Login Form Data

$oForm = _IEFormGetCollection($oIE, 0)

$oUserID = _IEFormElementGetCollection($oForm, 1)

$oPasswd = _IEFormElementGetCollection($oForm, 2)

$oLogin = _IEFormElementGetCollection($oForm, 3)

;Enter Data into Login Form Fields

_IEFormElementSetValue($oUserID, $PX_User)

_IEFormElementSetValue($oPasswd, $PX_Pass)

; Simulate a Mousee click on "Submit"

_IEAction($oLogin, "click")

;Wait for browser to finish loading...

_IELoadWait ($oIE)

;Get form data for User ID Search

$oForm = _IEFormGetCollection($oIE, 0)

$oAcct = _IEFormElementGetCollection($oForm, 10)

$oSearch = _IEFormElementGetCollection($oForm, 12)

;Pass Account information into form

_IEFormElementSetValue($oAcct, $acct)

;Simulate a Mouse click on "Search"

_IEAction($oSearch, "click")

;Wait for Page to Load

_IELoadWait($oIE)

$oTable = _IETableGetCollection($oIE)

$iNumTables = @extended

If $iNumTables <> 4 Then

_IEQuit($oIE)

MsgBox(0, "Error...", "Acct Search: " & $acct & " does not have any PayXpress Registrations!"& @CRLF & 'Click "OK" to Quit.')

Exit

EndIf

;Get Table with Data...

$oTable = _IETableGetCollection ($oIE,3)

Sleep(5000)

;Close the Browser Instance

_IEQuit($oIE)

; Load Table into Array...

$aTblArray=_IETableWriteToArray($oTable,True)

_ArrayDisplay($aTblArray)

; Other code follows....

Exit

If I have a large dataset returned, I keep getting, not always the same eventhough it's the same selection criteria.

The funny thing is, that the error doesn't always happen at the same time or with the dame error code, even though I'm using the same selection criteria.

Run 1:

C:\Program Files\AutoIt3\Include\IE.au3 (2059) : ==> The requested action with this object has failed.:

$i_col = $i_col + $td.colSpan

$i_col = $i_col + $td.colSpan^ ERROR

>Exit code: 1 Time: 32.575

Run 2:

>"C:\Program Files\AutoIt3\SciTE\..\autoit3.exe" /ErrorStdOut "C:\temp\GetAccts_PX.au3"

--> IE.au3 V2.3-1 Error from function _IETableWriteToArray, $_IEStatus_InvalidObjectType

>Exit code: 0 Time: 15.095

Run 3:

>"C:\Program Files\AutoIt3\SciTE\..\autoit3.exe" /ErrorStdOut "C:\temp\GetAccts_PX.au3"

C:\Program Files\AutoIt3\Include\IE.au3 (2056) : ==> The requested action with this object has failed.:

$tds = $tr.cells

$tds = $tr.cells^ ERROR

>Exit code: 1 Time: 18.667

Any help with this issue would greatly be appreciated. Even if there is any way to help debug this please let me know.

Richard Leatherman,

Operations,

Time Warner Cable, NEO

Share this post


Link to post
Share on other sites

What's up with this section of code?

;Get Table with Data...
$oTable = _IETableGetCollection ($oIE,3)
Sleep(5000)

;Close the Browser Instance
_IEQuit($oIE)

; Load Table into Array...
$aTblArray=_IETableWriteToArray($oTable,True)

The _IETableGetCollection returns an object variable pointing to a table, not the data in the table. If you quit the browser before you try to read what's in the table everything will fall apart.

Move your _IETableWriteToArray before the _IEQuit and I think you'll like the results a lot better.

Dale


Free Internet Tools: DebugBar, AutoIt IE Builder, HTTP UDF, MODIV2, IE Developer Toolbar, IEDocMon, Fiddler, HTML Validator, WGet, curl

MSDN docs: InternetExplorer Object, Document Object, Overviews and Tutorials, DHTML Objects, DHTML Events, WinHttpRequest, XmlHttpRequest, Cross-Frame Scripting, Office object model

Automate input type=file (Related)

Alternative to _IECreateEmbedded? better: _IECreatePseudoEmbedded  Better Better?

IE.au3 issues with Vista - Workarounds

SciTe Debug mode - it's magic: #AutoIt3Wrapper_run_debug_mode=Y Doesn't work needs to be ripped out of the troubleshooting lexicon. It means that what you tried did not produce the results you expected. It begs the questions 1) what did you try?, 2) what did you expect? and 3) what happened instead?

Reproducer: a small (the smallest?) piece of stand-alone code that demonstrates your trouble

Share this post


Link to post
Share on other sites

Thanks, Dale!

I was thinking what you said it didn't do, load the table with the _IETableGetCollection().

Richard

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