Get form name from iframe using AutoIt

Whitecat picture Whitecat · Jun 1, 2011 · Viewed 7.5k times · Source

I am using AutoIt to automate filling in forms on a website.

But I am having a problem getting the form name from a website. I look at the source of the HTML and find form and its name, but I still get a IEStatus_noMatch error.

Is there an easier way to get the form name or how to find it out?

I might face this same problem for objects.

$sUrl = "https://www.acgme.org/residentdatacollection/login.asp"
$oIE = _IEAttach($sUrl, "url")
If not isObj($oIE) Then
    $oIE = _IECreate()
    _IENavigate($oIE, $sUrl)
EndIf

; Get pointers to the login form and username and password fields
$o_form = _IEFormGetObjByName($oIE, "loginentry")
$o_login = _IEFormElementGetObjByName($o_form, "USERID")
$o_password = _IEFormElementGetObjByName($o_form, "PASSW")

Answer

Whitecat picture Whitecat · Jun 3, 2011

I got this answer from AutoIt forum here

There are two frames and the form is in the second frame so use $o_frame = _IEFrameGetCollection($oIE, 1) to get the second frame (index 1 is the second frame, index 0 would be the first).

Then get the form from the frame by using: $o_form = _IEFormGetObjByName($o_frame, "loginentry")

So that section of your code would look like:

; get pointers to the login form and username and password fields
$o_frame = _IEFrameGetCollection($oIE, 1)
$o_form = _IEFormGetObjByName($o_frame, "loginentry")

$o_login = _IEFormElementGetObjByName($o_form, "USERID")
$o_password = _IEFormElementGetObjByName($o_form, "PASSW")

USERID and PASSW are hidden fields so you won't see them filled in. If the form doesn't submit properly, use the visible field names:

$o_login = _IEFormElementGetObjByName($o_form, "posterior")
$o_password = _IEFormElementGetObjByName($o_form, "fossa"