我想使用powershell访问Jtrac网页。我能够登录,但我无法访问搜索按钮哪个href链接。powershell IE自动化href问题
$Url = “http://kbserver/workflow/app/login”
enter code here`$Username=”XXXXX”
enter code here`$Password=”XXXXX”
$IE = New-Object -com internetexplorer.application;
$IE.visible = $true;
$IE.navigate($Url);
while ($IE.Busy -eq $true)
{
Start-Sleep -Milliseconds 2000;
}
$Login = $IE.document.getElementById("loginName3").value = "$Username"
$Login = $IE.Document.getElementById(“password12”).value= "$Password"
$Login = $IE.Document.getElementsByTagName("input") | where-object {$_.type -eq "submit"}
$Login.click();
while ($IE.Busy -eq $true)
{
Start-Sleep -Milliseconds 5000;
}
$Login = $IE.Document.getElementsByTagName("a") | where {$_.href -eq "'?wicket:interface=:2:table:dashboardRows:3:dashboardRow:search::ILinkListen er::'"}
$Login.click();
错误,我得到是
你不能调用一个空值表达式的方法。 在C:\ Users \ Dinesh \ Webbb.ps1:20 char:13 + $ Login.click < < < <(); + CategoryInfo:InvalidOperation:(点击:字符串)[],RuntimeException的 + FullyQualifiedErrorId:InvokeMethodOnNull
<a href="?wicket:interface=:2:table:dashboardRows:3:dashboardRow:search::ILinkListener::">
<img title="SEARCH" src="../resources/search.gif"> </a>
对不起。当我粘贴在这里的错字错误... –
我已根据您的信息更新了我的答案。 – Phil
仍然没有运气,得到同样的错误。 –