【发布时间】:2017-03-31 00:04:38
【问题描述】:
打开站点后,该框架菜单栏内有一个框架是他们的,并且在该菜单栏中 5 按钮是他们的示例:-
搜索(e 下划线,下拉箭头也有搜索)和窗口(W 下划线,下拉箭头也有窗口)我想点击搜索。
我尝试使用href,id,但无法点击搜索。
$Url = “some site”
$Username=”xxx”
$Password=”xxx”
$IE = New-Object -com internetexplorer.application;
$IE.visible = $true;
$IE.navigate($url);
while ($IE.Busy -eq $true)
{
Start-Sleep -Milliseconds 2000;
}
$IE.Document.getElementById(“USERNAME”).value = $Username
$IE.Document.getElementByID(“PIN”).value=$Password
$IE.Document.getElementById(“HardcodedSub”).Click()
while($ie.busy) {sleep 5}
$Link = $ie.Document.getElementsByTagName("a") | where-object {$_.id -eq 'menu_2'}
$Link.click()
error:-You cannot call a method on a null-valued expression.
At line:25 char:1
+ $Link.click()
+ ~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (:) [], RuntimeException
+ FullyQualifiedErrorId : InvokeMethodOnNull
inspect element:-
<a id="menu_2" tabindex="2" class="menu_unselected_text" href="javascript:window.parent.role_main.cai_main.setActKeyMenuState(2)">S<u>e</u>arch<img border="0" src="/CAisd/img/arrow_asc_bk.png" width="15" height="10"></a>
【问题讨论】:
标签: powershell powershell-3.0 powershell-4.0