【发布时间】:2020-07-07 12:28:18
【问题描述】:
我正在尝试使用 powershell 在两个文本框中输入文本。我可以在第一个框中输入一个值,但不能在第二个框中输入值。这是因为我不知道如何隔离第二个文本框,因为它与第一个文本框具有相同的代码,包括 ID、类、标记名等。
下面是我的代码,其中的 URL 被取出(由于工作)。我最初想通过在第一个文本框的值上使用 -ne 来隔离第二个文本框,因为通过输入一个值来区分代码,但这似乎不起作用。我是编码新手,所以如果我表达自己不好,我深表歉意,但您可以提供的任何帮助将不胜感激。
$Web = "URL"
$Internet = New-Object -ComObject InternetExplorer.Application
$Internet.visible = $true
$Internet.Navigate($web)
While($Internet.Busy -eq $true){
Start-Sleep -Seconds 1
}
$Internet.document.getElementById("filterValue").value="Number"
$link = $Internet.Document.getElementsByTagName('a') | where-object {$_.innerText -eq 'Next Prompt'}
$link.click()
While($Internet.Busy -eq $true){
Start-Sleep -Seconds 1
}
**#Question about coding starts here**
$Input = $Internet.Document.IHTMLDocument3_getElementById("filterValue")
$Input.value = "1/1/2020"
While($Internet.Busy -eq $true){
Start-Sleep -Seconds 1
}
$Input2 = $Internet.Document.IHTMLDocument3_getElementById("filterValue") | ? {$_.value -ne "1/1/2020"}
Start-Sleep -Seconds 4
$Input2.value = "1/2/2020"
【问题讨论】:
标签: powershell internet-explorer automation