使用PowerShell填充Web文本框并按下按钮

时间:2018-01-12 15:01:49

标签: powershell internet-explorer button web click

我正在尝试使用powershell来自动打开IE并在文本框中放置一个值并按下按钮。

Add-Type -AssemblyName Microsoft.VisualBasic 
cls
$orderID = "text box entry" 
$smoURL = "URL"
$iterator = 1;

Write-Host ("ID = $orderID")

$orderIDTextBox = "txtOrderID"
$searchButton = "btnSearch"

$IE = New-Object -ComObject InternetExplorer.Application
$ie.visible = $true
$ie.navigate("$smoURL")
While ($IE.Busy -eq $true) {Start-Sleep -Milliseconds 2000} 

    Start-Sleep -Seconds 3

$ie.Document.getElementById("$orderIDTextBox").value = "$orderID"
$Submit = $ie.Document.getElementsByTagName("$btnSearch") 
$Submit.click()

我已经打开了网站,但是当我尝试填充文本字段时,我收到以下错误消息:

enter image description here

This is the inspect element on the webpage.

这是网页上的检查元素。

0 个答案:

没有答案