我正在尝试设置一个PowerShell,它将把我登录到我儿子的学校门户网站并提交所需的表格。我每天都要做一个,我得到了一个很好的想法,那就是我可以编写它的脚本。下面是脚本和错误
$ie = New-Object -ComObject 'internetExplorer.Application'
$ie.Visible= $true # Make it visible
$username="Username"
$password="Password"
$ie.Navigate("https://parents.genesisedu.com/hasbrouckheights/parents?module=home&studentid=1000333&action=form")
While ($ie.Busy -eq $true) {Start-Sleep -Seconds 3;}
$usernamefield = $ie.document.getElementByID('j_username')
$usernamefield.value = "$username"
$passwordfield = $ie.document.getElementByID('j_password')
$passwordfield.value = "$password"
$Link = $ie.Document.getElementsByClassName(“saveButton”)[0].value="Login"
$Link.click()
Method invocation failed because [System.String] does not contain a method named 'click'.
At line:19 char:1
+ $Link.click()
+ ~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (:) [], RuntimeException
+ FullyQualifiedErrorId : MethodNotFound
我尝试了很多变体,但似乎无法让它达到";登录";按钮任何帮助都将不胜感激。。。
**************网站信息************************
<input type="submit" class="saveButton" style="color: #000000;background-color: #e0e0e0; font-weight: 500;" value="Login">
<input type="button" class="saveButton" value="Forgot My Password" style="background-color:#e0e0e0; border:transparent; cursor:pointer;color:#000; font-size: 12pt; font-weight:500" onclick="forgotMyPassword();">
感谢
您当前在调用Click()
之前将字符串值"Login"
分配给$Link
,因此出现错误。
更改此项:
$Link = $ie.Document.getElementsByClassName(“saveButton”)[0].value="Login"
至:
$Link = $ie.Document.getElementsByClassName(“saveButton”)[0]