我正在编写PowerShell脚本以登录到网站并下载一些报告。我几乎不了解PowerShell。
我已经能够将科学怪人的脚本一起登录,但是单击菜单按钮时遇到问题。检查元素将按钮(在这种情况下,标记为“ abc”)显示为:
<a class="category-item-text" href="#">abc</a>
我当前的脚本如下:
$ie.Visible= $true # Make it visible
$username="MYUSERNAME"
$password="MYPASSWORD"
$ie.Navigate("https://MY.WEBPAGE/yada/yada/yada")
While ($ie.Busy -eq $true) {Start-Sleep -Seconds 3;}
$usernamefield = $ie.document.getElementByID('LOGIN_FIELD_LABEL')
$usernamefield.value = "$username"
$passwordfield = $ie.document.getElementByID('PASSWORD_FIELD_LABEL')
$passwordfield.value = "$password"
$Click=$ie.Document.getElementsByTagName("button") | Where-Object {$_.type -eq 'submit'}
$Click.click()
While ($ie.Busy -eq $true) {Start-Sleep -Seconds 3;}
$ie.Navigate("https://MY.WEBPAGE/yada/yada/REPORTS")
While ($ie.Busy -eq $true) {Start-Sleep -Seconds 3;}
任何帮助将不胜感激!
答案 0 :(得分:0)
这对我有用。我需要使用getElementsByTagName(“ a”):
$ Click = $ ie.Document.getElementsByTagName(“ a”)|哪里对象{$ _。href -match'abc'} $ Click.click()