gpt4 book ai didi

html - 自动化 (IE ComObject) 填充文本框

转载 作者:太空狗 更新时间:2023-10-29 13:17:05 25 4
gpt4 key购买 nike

我正在尝试自动化 Outlook Web Access 网站,填写一些文本框并单击按钮,

我可以在第一页(登录)和提交按钮中找到相关元素,所以我通过了登录阶段,我的问题是在一些带有屏蔽文本框的页面中找到元素,我附上了快照3个步骤,还有对象的DOM图片。

The Login Page

$IE = New-Object -ComObject InternetExplorer.Application
$URL = 'https://somewebsite/ecp/?rfr=owa&p=PersonalSettings/Password.aspx'
$IE.Visible = $true
$IE.Navigate($URL)
While ($IE.Busy -eq $true) {Start-Sleep -Milliseconds 2000}

$ie.Document.getElementById('username').value = "username"
$ie.Document.getElementById('password').value = "password"
$Submit = $ie.Document.getElementsByTagName('Input') | ? {$_.Type -eq "Submit"}
$Submit.click()

到目前为止一切顺利,我的问题从里面的页面开始,我只是找不到密码字段的文本框元素,

enter image description here

还有这些元素的 DOM 快照:

enter image description here

非常感谢任何帮助

最佳答案

我在尝试 automate a file upload on sharepoint 时遇到了同样的问题.诀窍在于上传表单在新框架内打开。

<iframe id="Dlg..." class="ms-dlgFrame" src="https://.../Upload.aspx?List=..."></iframe>

因此,为了获得输入字段,我必须查看每个打开的框架并选择位置合适的框架:

for($i=0;$i -lt $ie.Document.frames.length;$i++){
if( $ie.Document.frames.item($i).location.href -match 'upload.aspx' ){
$frm=$ie.Document.frames.item($i)}
}

从那时起我就可以定位输入字段了:

$frm.document.body.getElementById("txtOldPwd") 

关于html - 自动化 (IE ComObject) 填充文本框,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33124235/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com