这完全陌生,我无法获取代码来单击并激活网页上的tabbutton,我要激活的网站部分是
class =“ tabButton EngagementsHistoryTable”
“网络历史记录”
<ul class="tabs_manager_buttons_container lpview_tabs_manager_buttons_container">
<li class="lpview_underLine underLine" style="left: 0px; width: 132px;
display: block;"></li>
<li class="tabButton VisitorListTable first active">
<span class="lpview_tabButton tabButtonText" title="Web Visitors"
tooltip-align="left" tooltip-delay="1500" tooltip-text="Web Visitors">Web
Visitors</span></li>
<li class="tabButton EngagementsHistoryTable">
<span class="lpview_tabButton tabButtonText" title="Web History" tooltip-
align="left" tooltip-delay="1500" tooltip-text="Web History">Web
History</span>
</li>
<li class="tabButton AgentListTable"><span class="lpview_tabButton
tabButtonText" title="Agents" tooltip-align="left" tooltip-delay="1500"
tooltip-text="Agents">Agents</span></li>
</ul>
下面的代码执行点击,但是什么也没发生。
For Each element As HtmlElement In WebBrowser1.Document.GetElementsByTagName("li")
If element.GetAttribute("className") = "tabButton EngagementsHistoryTable" Then
element.InvokeMember("click")
End If
Next
答案 0 :(得分:0)
感谢CruleD,我可以通过执行以下操作来使其工作
For Each element As HtmlElement In WebBrowser1.Document.GetElementsByTagName("span")
If element.GetAttribute("className") = "lpview_tabButton tabButtonText" Then
If element.GetAttribute("InnerText") = "Web History" Then
element.InvokeMember("click")
End If
End If
Next
答案 1 :(得分:0)
通过类似方法调用日历时
For Each element As HtmlElement In WebBrowser1.Document.GetElementsByTagName("span")
If element.GetAttribute("className") = "filterButton lpview_filterButton EngagementsHistoryTableViewController_filterId6 filter_on" Then
element.InvokeMember("click")
End If
Next
来自Cal
<td class=" ui-datepicker-week-end ui-datepicker-current-day" data-handler="selectDay" data-event="click" data-month="5" data-year="2018"><a class="ui-
state-default ui-state-active ui-state-hover" href="#">24</a></td>
致人
<td class=" ui-datepicker-days-cell-over ui-datepicker-current-day ui-datepicker today" data-handler="selectDay" data-event="click" data-month="6" data-year="2018"><a
class="ui-state-default ui-state-highlight ui-state-active" href="#">4</a></td>