Get form name from iframe using AutoIt
Asked Answered
L

2

6

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")
Liba answered 1/6, 2011 at 15:52 Comment(0)
L
7

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"
Liba answered 3/6, 2011 at 21:26 Comment(0)
C
1

You are using the wrong function to get the form object... _IEForm*Element*GetObjByName is for form sub-elements. You should use the _IEFormGetObjByName function instead.

Cleaver answered 2/6, 2011 at 8:59 Comment(1)
That is a good answer but.. IT doesn't actually fix the problem. I have made the change. But I still get the $_IEStatus_NoMatch with the web site in the example.Liba

© 2022 - 2024 — McMap. All rights reserved.