html - 使用 AutoIt 从 iframe 获取表单名称

标签 html internet-explorer autoit

我正在使用 AutoIt在网站上自动填写表格。

但是我在从网站获取表单名称时遇到了问题。我查看了 HTML 的源代码并找到了表单及其名称,但我仍然收到 IEStatus_noMatch 错误。

是否有更简单的方法来获取表单名称或如何找到它?

对于对象,我可能会遇到同样的问题。

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

最佳答案

我从 AutoIt 论坛得到了这个答案 here

有两个框架,表单在第二个框架中,所以使用 $o_frame = _IEFrameGetCollection($oIE, 1) 获取第二个框架(索引 1 是第二个框架,索引 0 会成为第一个)。

然后使用以下方法从框架中获取表单:$o_form = _IEFormGetObjByName($o_frame, "loginentry")

所以你的代码部分看起来像:

; 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 和 PASSW 是隐藏字段,因此您不会看到它们已填写。如果表单未正确提交,请使用可见字段名称:

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

关于html - 使用 AutoIt 从 iframe 获取表单名称,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6204021/

相关文章:

javascript - 如何从 Protractor 脚本中调用 AutoIt 函数?

html - Bootstrap 3 按钮呈现不良 CSS 且未对齐

css - IE z-index 错误无法正确显示 div

javascript - js打印功能在ie9下不起作用

windows - 如何自动化 "Windows Security"窗口: "Windows can' t verify the publisher of this driver software"

python - 在 python 中自动化 IE、MS-Office 设置验证的最佳方法

html - 将图像相互放置,位置为 :absolute without using top

javascript - AngularJS:更改 HTML 字符串的编码

html - CSS3 - 宽度 :100% - Height:Auto - Background-image?

html - IE/Edge 上的左省略号溢出