【发布时间】:2016-02-24 02:47:51
【问题描述】:
我目前正在使用 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>
【问题讨论】:
标签: javascript powershell