PowerShell 脚本,用于单击 JavaScript 按钮
PowerShell script to click a JavaScript Button
我目前正在处理PowerShell脚本以启动页面并单击按钮。该按钮是一个 JavaScript 按钮,没有<<>>标签。两个变体都返回 不能对空值表达式调用方法。我确定我正在绕出答案,但我仍然处于持有模式。提前感谢!
$ie = new-object -com internetexplorer.application
$ie.visible=$true
$ie.navigate('http://192.168.63.10/counters/usage.php')
while($ie.busy) {sleep 1}
$link = @($ie.Document.getElementsByTagName('button')) | Where-Object {$_.innerText -eq 'Download File to Your Computer'}
$link.click()
我也试过:
$link2 = $ie.Document.documentElement.getElementsByClassName('horizButtonBarAboveTableLeft')| Where-Object {$_.innerText -eq 'Download File to Your Computer'}
$link2.click()
这是 HTML(希望使用 GenerateCsvFile() 单击按钮:)
<div class="horizButtonBarAboveTableLeft">
<button onclick="document.location=document.URL">
<img src="/images/counters/refresh_renew_32.png" alt="" width="32" height="32">
Refresh </button>
<img src="/images/ClearGIF.gif" width="19" height="20" alt="">
<button onclick="GenerateCsvFile();">
<img src="/images/counters/download_import_32.png" alt="" width="32" height="32">
Download File to Your Computer </button>
您的 Where-Object 子句失败,因为 innerText 中有额外的空格,导致相等条件失败。 因此,$link
变量为空。然后,这会导致You cannot call a method on a null-valued expression
错误。 尝试修剪空格。
Where-Object { $_.innerText.Trim() -eq 'Download File to Your Computer' }
相关文章:
- Javascript按钮下拉列表
- ASP.NET通过单击JavaScript按钮触发c#事件
- JavaScript按钮/输入/函数,字符串反转
- 测试一个简单的javascript按钮
- 如果函数返回True,则显示Javascript按钮
- 用Javascript按钮替换Javascript超链接
- 从页面javascript按钮运行Node.JS
- 如何在asp.net上应用javascript按钮点击
- Javascript按钮href注入
- 计时器自动运行,而不是单击javascript按钮
- Javascript按钮,在html文本区域中插入一个大黑点(•)
- 单击javascript按钮显示/隐藏Div元素
- 单击Javascript按钮,将值添加到文本框中
- visualforce页面javascript按钮点击不起作用
- 使javascript按钮隐藏或显示内容切换
- 使用 Scrapy 模拟 JavaScript 按钮点击
- Javascript按钮禁用并启用特定时间
- 如果未输入任何内容,则使 JavaScript 按钮不执行任何操作
- 当表为空时禁用 JavaScript 按钮
- javascript按钮在html中不起作用