开发者

Get form name from iframe using AutoIt

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"开发者_如何学Go)


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"


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜