我在网页上有一个按钮列表。我可以使用Get Class Name函数获取按钮列表。但我无法迭代它。
以下是代码:
main role="main">
<div class="wrapper">
</div>
<div class="wrapper wrapper-medium">
<header>
<h1>Unsubmitted Timesheets</h1>
<div class="clearfix">
<div class="fl-left">
<select name="" id="select-timeframe" class="hui-input"><option value="/missing_time/period/36/2018">05 Feb 2018 - 11 Feb 2018</option>
<option selected="selected" value="/missing_time/period/29/2018">This Week</option>
<option value="/missing_time/period/22/2018">22 Jan 2018 - 28 Jan 2018</option>
<option value="/missing_time/period/15/2018">15 Jan 2018 - 21 Jan 2018</option>
<option value="/missing_time/period/8/2018">08 Jan 2018 - 14 Jan 2018</option>
<option value="/missing_time/period/29/2018?all_weeks=1">- show all weeks -</option></select>
</div>
<div class="fl-right">
<button type="button" class="hui-button" data-open-dialog="email-reminder-dialog">
<i data-icon="check-green"></i>
Sending Reminder Every Friday
</button>
</div>
</div>
</header>
<section>
<form id="missing-time-form" action="/missing_time/reminders?return_to=%2Fmissing_time%2Fperiod%2F29%2F2018" accept-charset="UTF-8" method="post"><input name="utf8" type="hidden" value="?"><input type="hidden" name="authenticity_token" value="YmA26BT5bHy1NQKiKks+j/nKl5saFnF2fAmp/Oy6zuWANPkuuMLYTZDtdZHa/7TNh2CcUx5R2e0FsPWOxThVoQ==">
<table id="unsubmitted-timesheets" class="table">
<thead>
<tr>
<th></th>
<th>
Team Members<br>
<small>
Select:
<button type="button" class="button-link js-toggle-all-users">All</button>
/
<button type="button" class="button-link js-toggle-no-users">None</button>
</small>
</th>
<th class="text-right">Time</th>
<th></th>
</tr>
</thead>
<tbody class="has-clickable-table-rows" data-required-checkboxes="You must select at least one recipient.">
<tr class="clickable-row">
<td class="col-checkbox">
<div class="hui-checkbox">
<input name="send_reminder[1964976]" type="hidden" value="0"><input class="checkbox" aria-label="Send Reminder for Alexander Cubillos" type="checkbox" value="1" name="send_reminder[1964976]" id="send_reminder_1964976">
<label for="send_reminder_1964976"></label>
</div>
</td>
<td>
Alexander Cubillos
<span class="text-label">Contractor</span>
<label for="send_reminder_1964976" class="clickable-row-link"></label>
</td>
<td class="text-right">
24:00
<label for="send_reminder_1964976" class="clickable-row-link"></label>
</td>
<td class="col-actions">
<a class="hui-button hui-button-tiny" href="/entry/show/29/2018?of_user=1964976">View Timesheet</a>
</td>
</tr>
<tr class="clickable-row">
<td class="col-checkbox">
<div class="hui-checkbox">
<input name="send_reminder[1840318]" type="hidden" value="0"><input class="checkbox" aria-label="Send Reminder for Allain Dollete" type="checkbox" value="1" name="send_reminder[1840318]" id="send_reminder_1840318">
<label for="send_reminder_1840318"></label>
</div>
</td>
<td>
Allain Dollete
<label for="send_reminder_1840318" class="clickable-row-link"></label>
</td>
<td class="text-right">
24:30
<label for="send_reminder_1840318" class="clickable-row-link"></label>
</td>
<td class="col-actions">
<a class="hui-button hui-button-tiny" href="/entry/show/29/2018?of_user=1840318">View Timesheet</a>
</td>
</tr>
<tr class="clickable-row">
<td class="col-checkbox">
<div class="hui-checkbox">
<input name="send_reminder[1882520]" type="hidden" value="0"><input class="checkbox" aria-label="Send Reminder for Anil Khemchandani" type="checkbox" value="1" name="send_reminder[1882520]" id="send_reminder_1882520">
<label for="send_reminder_1882520"></label>
</div>
</td>
<td>
Anil Khemchandani
<span class="text-label">Contractor</span>
<label for="send_reminder_1882520" class="clickable-row-link"></label>
</td>
<td class="text-right">
0:00
<label for="send_reminder_1882520" class="clickable-row-link"></label>
</td>
<td class="col-actions">
<a class="hui-button hui-button-tiny" href="/entry/show/29/2018?of_user=1882520">View Timesheet</a>
</td>
</tr>
<tr class="clickable-row">
<td class="col-checkbox">
<div class="hui-checkbox">
<input name="send_reminder[1028098]" type="hidden" value="0"><input class="checkbox" aria-label="Send Reminder for Anna Jhaveri" type="checkbox" value="1" name="send_reminder[1028098]" id="send_reminder_1028098">
<label for="send_reminder_1028098"></label>
</div>
</td>
<td>
Anna Jhaveri
<label for="send_reminder_1028098" class="clickable-row-link"></label>
</td>
<td class="text-right">
0:00
<label for="send_reminder_1028098" class="clickable-row-link"></label>
</td>
<td class="col-actions">
<a class="hui-button hui-button-tiny" href="/entry/show/29/2018?of_user=1028098">View Timesheet</a>
</td>
</tr>
<tr class="clickable-row">
<td class="col-checkbox">
<div class="hui-checkbox">
<input name="send_reminder[1399194]" type="hidden" value="0"><input class="checkbox" aria-label="Send Reminder for Chaitanya Potluri" type="checkbox" value="1" name="send_reminder[1399194]" id="send_reminder_1399194">
<label for="send_reminder_1399194"></label>
</div>
</td>
<td>
Chaitanya Potluri
<span class="text-label">Contractor</span>
<label for="send_reminder_1399194" class="clickable-row-link"></label>
</td>
<td class="text-right">
40:00
<label for="send_reminder_1399194" class="clickable-row-link"></label>
</td>
<td class="col-actions">
<a class="hui-button hui-button-tiny" href="/entry/show/29/2018?of_user=1399194">View Timesheet</a>
</td>
</tr>
<tr class="clickable-row">
<td class="col-checkbox">
<div class="hui-checkbox">
<input name="send_reminder[1908612]" type="hidden" value="0"><input class="checkbox" aria-label="Send Reminder for Daniel Pedraza Mena" type="checkbox" value="1" name="send_reminder[1908612]" id="send_reminder_1908612">
<label for="send_reminder_1908612"></label>
</div>
</td>
<td>
我希望点击一个按钮到下一页执行一些操作,然后返回到第一页。然后转到下一个按钮。应该重复此操作,直到访问所有按钮。我一直在讨厌它,但我无法想出解决方案。
我试过这样做,但它只针对第一个或最后一个按钮
($ie.Document.GetElementsByClassName("hui-button hui-button-tiny") |
Select-Object -First 1).Click()
($ie.Document.GetElementsByClassName("hui-button hui-button-tiny") |
Select-Object -Last 1).Click()
如果我这样做 -
$ViewTimessheetObject=($ie.document.getElementsByClassName("hui-button hui-button-tiny") |Select-Object -first 1)
while($ie.Busy) { Start-Sleep -Milliseconds 100 }
($ViewTimesheetObject | ForEach-Object {$_.Click()})
它抛出一条错误消息,指出“你无法在空值表达式上调用方法。+($ ViewTimesheetObject | ForEach-Object {$ _。Click()})
非常感谢任何有关此事的帮助。
答案 0 :(得分:0)
你的foreach应该是$ie.document.getElementsByClassName
($ie.document.getElementsByClassName("hui-button hui-button-tiny")) | Foreach { $_.Click()}