I tried many different ways to click submit button on HTML code, but always got error.
<form action="abnormal-times.aspx" method="post">Time out Minutes <input name="Minutes" style="width: 100px;" value="5"> Minutes.<br>Time out Hours <input name="Minutes" style="width: 100px;" value="2"> Hours.<input onclick="submit()" type="button" value="submit">
With my powershell code:
$ie = New-Object -com InternetExplorer.Application $ie.visible = $true$ie.navigate("http://localhost.com")while($ie.ReadyState -ne 4) { start-sleep -s 1 }$Link = $ie.Document.getElementsByValue("submit")$Link.click()
But always popup error.
Method invocation failed because [mshtml.HTMLDocumentClass] doesn't contain a method named 'getElementsByValue'.At C:\temp\Untitled1.ps1:28 char:42+ $Link = $ie.Document.getElementsByValue <<<< ("submit")+ CategoryInfo : InvalidOperation: (getElementsByValue:String) [], Run timeException+ FullyQualifiedErrorId : MethodNotFoundYou cannot call a method on a null-valued expression.At C:\temp\Untitled1.ps1:29 char:14+ $Link.click <<<< ()+ CategoryInfo : InvalidOperation: (click:String) [], RuntimeException+ FullyQualifiedErrorId : InvokeMethodOnNull
Now I changed into this:
$Link=$ie.Document.getElementsByTagName("button") | where-object {$_.type -eq "submit"}$Link.click()
The error came out:
You cannot call a method on a null-valued expression.At C:\Users\Work_Server\Desktop\joseph.ps1:29 char:10+ $go.click <<<< ()+ CategoryInfo : InvalidOperation: (click:String) [], RuntimeException+ FullyQualifiedErrorId : InvokeMethodOnNull