gpt4 book ai didi

user-interface - 通过 PowerShell 填写 Web 表单无法识别输入的值

转载 作者:行者123 更新时间:2023-12-04 04:26:31 26 4
gpt4 key购买 nike

作为 QA 工作,我需要通过 Web 表单填写大量申请。
想法是将个人数据放在一些 xls/txt/whatever 文件中,读取文件并使用 Powershell 将数据提供给浏览器。

当我使用下面的代码在 IE 中填写表单时,即使它看起来工作正常,但在提交表单时出现未输入数据的错误。

任何如何解决这个问题的想法或建议将不胜感激

遗憾的是,我的资源仅限于 Powershell 2.0。 Selenium 或任何其他“更复杂”的工具至少目前是没有问题的。

validation error here

$ie = New-Object -com InternetExplorer.Application
$ie.Navigate("MyURL")
$ie.visible = $true

while ($ie.ReadyState -ne 4){sleep -m 100}

Function ClickById($id) {
$ie.document.getElementById($id).Click()
}

### Základní údaje
$FnId = 'personalData.firstName'
$LnId = 'personalData.lastName'
$PhoneId = 'personalData.mobilePhone'
$EmailId = 'personalData.email'
$DataAgreementCheckBox = 'application.personalDataAgreement'
$SubmitfwdId = 'forward'


$Values = "Ublala", "Pung", "222333444", "ublala@pung.com"
$Ds1Elements = $FnId, $LnId, $PhoneId, $EmailId

$j = 0
foreach ($El in $Ds1Elements) {
$ie.document.getElementById($El).value = $values[$j]
$j++
}

ClickById $DataAgreementCheckBox
ClickById $SubmitfwdId

最佳答案

感谢您的建议,但它不起作用,因为该表格在许多方面似乎都很愚蠢。
无论如何,在使用 SendKeys 方法时,我使用了您的建议作为重点,它成功了。

一开始我需要加载这个程序集

[void] [System.Reflection.Assembly]::LoadWithPartialName("'System.Windows.Forms")

然后相应地更改循环以使用 SendKeys 方法
$j = 0
foreach ($El in $Ds1Elements) {
$ie.document.getElementById($El).focus()
[System.Windows.Forms.SendKeys]::Sendwait($values[$j]);
$j++
}

并且 tradaaaa 表格已填写,没有人提示:)

关于user-interface - 通过 PowerShell 填写 Web 表单无法识别输入的值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33216366/

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