通过PowerShell自动执行Internet浏览 - 选中多个不起作用的复选框

时间:2015-07-29 15:33:11

标签: internet-explorer powershell

  

登录网站

$usernameMI = "myusername"
$passwordMI = "mypassword"

$ie = New-Object -com InternetExplorer.Application
$ie.visible = $true
$ie.navigate("https://mobility-vsp1.corp.com/mifs/login.jsp")
while($ie.ReadyState -ne 4) {start-sleep -m 100}
$ie.document.getElementById("username").value= $usernameMI
$ie.document.getElementById("password").value = $passwordMI
$ie.document.getElementById("login-btn").click();
  

以下部分将提示输入姓名,然后搜索设备和用户

while($ie.busy -eq $ture) 
{
start-sleep -milliseconds 1000;
}


$Devicesearch = Read-Host 'Enter email alias (Example: First.Last)'
$ie.document.getElementById("simpleSearch-1099-inputEl").value = $Devicesearch
$ie.document.getElementById("ext-gen1231").click();
  

这是我无法选中复选框的位置(此复选框会在单击时选中所有复选框)

     

为了做到这一点,我尝试拔出嵌入对象,这将给复选框一个我可以操作的值,但我还没有让它工作。

     

我已经尝试了id.document.getElementById(“gridcolumn-1145-textEl”)。点击没有管道,但是无法正常工作

$chkbox = $ie.document.getElementById("gridcolumn-1145-textEl")
($chkbox | where {$_.tagName -eq "x-grid-row-checker-on"}).selected

1 个答案:

答案 0 :(得分:0)

我认为你点击了错误的元素。 请你检查一下" ext-gen1231"查看它是否具有onclick值。 我刚刚完成了这个,并且有两个具有相似标题的元素,我点击了第二个元素并且它有效。