【问题标题】:How to apply click event on html tree node using power shell?如何使用 power shell 在 html 树节点上应用点击事件?
【发布时间】:2018-11-28 14:29:34
【问题描述】:

我正在尝试使用 power shell 自动执行一项重复活动。实际上,脚本应该登录到页面并展开 div 标签下可用的树节点。 Tree view

DOM Code 这是我的代码 sn-p。由于隐私原因,我没有提供示例 URL。

$url = "url of my application"
$username="userName"
$password="ChangeMe"

$ie = New-Object -ComObject InternetExplorer.Application
$ie.Visible = $true
$ie.navigate($url);


while ($ie.Busy -eq $true)
{
    Start-Sleep -Milliseconds 1000;
}

$ie.Document.getElementById("IDToken1").value = $username
$ie.Document.getElementByID("IDToken2").value=$password
$ie.Document.getElementById("Login.Submit").Click();



Start-Sleep -Seconds 15
while ($ie.Busy -eq $true)
{
    Start-Sleep -Milliseconds 1000;
}


$Option = $ie.Document.getElementsByClassName('span12') | Where-Object  {$_.innerText -eq 'FBN'} 

$Option.Click();

exit

执行后,我可以成功登录网页,但无法应用单击/展开树节点,并通过不同的建议尝试了多种方法,但没有出现以下错误的 lunk..

您不能在空值表达式上调用方法”

请建议任何其他替代方法以进一步发展。

【问题讨论】:

    标签: html powershell scripting


    【解决方案1】:

    我玩了一下,我不确定它是否可以完成。

    很多html和js代码都是页面加载后生成的。如果您查看实际的 html 代码(查看源代码)。

    顺便说一句,即使搜索页面的 ElementByID,我也遇到了同样的错误。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多