我只能突出显示该行,但不能双击TR来触发事件并转到下一页。
这是我的VBA代码:
Set table = webpage.Document.getElementsByClassName("grid-mvc")(0).getElementsByTagName("div")(0).getElementsByTagName("table")(0).getElementsByTagName("tbody")(0).getElementsByTagName("tr")(0)
'Double Click on row
For Each RowElement In table.getElementsByClassName("grid-cell")
MsgBox RowElement.innerText
RowElement.Click
RowElement.Focus
RowElement.FireEvent "ondblclick", 1, 2
RowElement.Focus
SendKeys "{ENTER}"
RowElement.FireEvent ("ondbclick")
SendKeys "{ENTER}"
RowElement.FireEvent ("ondbclick")
RowElement.FireEvent ("onmousedown")
'RowElement.dispatchEvent ("ondblclick")
SendKeys "{ENTER}"
RowElement.getElementsByTagName("td")(1).Click
If Trim(RowElement.getElementsByTagName("td")(0).innerText) = Value Then
MsgBox RowElement.textContent
RowElement.getElementsByTagName("td")(0).Click
End If
Next
HTML代码:
<TBODY>
<TR class="grid-row ">
<TD class="grid-cell" data-name="FacilityID">49343</TD>
<TD class="grid-cell" data-name="SubBrand">QQ</TD>
<TD class="grid-cell" data-name="PMSType">OnQ</TD>
<TD class="grid-cell" data-name="PMSAccountingID">ORNA </TD>
<TD class="grid-cell" data-name="PMSIDDesc"></TD>
<TD class="grid-cell" data-name="AccountingIDFullAcct">
<DIV class="GLAccount">99 90700 USD</DIV></TD>
<TD class="grid-cell" data-name="AccountDescription">
<DIV title="Charitable Contributions "
class="GLAccountDesc">Charitable Contributions </DIV></TD>
<TD class="grid-cell" data-name="AccountingID">2861</TD>
<TD class="grid-cell" data-name="StartDate">12/7/2018</TD>
<TD class="grid-cell" data-name="EndDate">12/31/2078</TD>
<TD class="grid-cell" data-name="CodeBlockSpecific">No</TD>
<TD class="grid-cell" data-name="SystemDefault">No</TD>
<TD class="grid-cell" data-name="PermissionLevel">Permitted</TD>
<TD class="grid-cell" data-name="UserID">MERE</TD>
<TD class="grid-cell" data-name="LastUpdateTime">
<DIV class="LastUpdateTime">12/7/2018 11:02:00 PM</DIV></TD>
<TD class="grid-cell" data-name="MgmtGroup">Franchised</TD>
<TD class="grid-cell" data-name="AcctType">Franchised</TD>
<TD class="grid-cell" data-name="FinSys">
<DIV title="Franchise" class="FinancialSystem">Franchise</DIV></TD>
<TD class="grid-cell" data-name="Inncode">SEACU</TD>
<TD class="grid-cell" data-name="HotelName">
<DIV title="The Charter Hotel Seattle, WA" class="HotelName">The Charter
Hotel Seattle, WA</DIV></TD></TR></TBODY></TABLE>
<DIV class="grid-footer">
<DIV class="grid-itemscount"><SPAN class="grid-itemscount-label">Total
Count:</SPAN> <SPAN class="grid-itemscount-caption">1</SPAN>
</DIV></DIV></DIV></DIV></DIV></DIV>
<DIV id="MappingSearchFacilityIdDialog"></DIV>
<DIV id="ApplyBrandDefaultMappingDialog"></DIV>
<SCRIPT>
答案 0 :(得分:0)
我可以看到您仅使用Click()。它不会双击也不触发任何事件。
要触发任何事件,您可以尝试使用以下代码。
objElement.click
objElement.FireEvent "ondblclick", 1, 2
参考: