html - 如何使用 VBA 在 Internet Exlorer 中单击 SPAN 元素
问题描述
我试图点击我使用用户名和密码访问的网站上的 span 元素,我尝试了所有可能的方法(大部分都在这个网站上找到)。也许你可以帮助我,这是我正在使用的代码:
Sub internet_explore()
Dim ie As InternetExplorer
Dim page As HTMLDocument
Set ie = CreateObject("internetexplorer.application")
ie.Visible = True
ie.Navigate2 "TheWebPage"
Do While ie.readyState <> READYSTATE_COMPLETE
DoEvents
Loop
'Here I enter code to do the login and make a search by filling an input box and clicking on search button
'wait for the search to load up
Do While ie.readyState <> READYSTATE_COMPLETE
DoEvents
Loop
Set page = ie.Document
Dim e as HTMLElementCollection
Dim c As HTMLButtonElement
For Each e In page.getElementsByTagName("span")
If e.innerText = "10.180.9.1" Then
Set c = e
c.click
c.parentElement.click
End If
Next
End Sub
这是我搜索的内容和我单击的按钮: 我搜索的内容
我得到的结果(表)以及为什么我需要单击该跨度元素,因为我得到了很多结果: 结果
<div class="x-grid3-cell-inner x-grid3-col-column7" style="CURSOR: pointer" unselectable="on">
<span class="Grid-Panel-All">10.180.9.1<div>
解决方案
推荐阅读
- vue.js - vue2-autocomplete-js 不像文档中提到的那样工作
- reactjs - 如何在组件类上调用 setTimeOut
- reactjs - MongoDB - SyntaxError:$regex 中的正则表达式无效
- java - 谁负责 JavaDoc 工具的文档和实现?
- r - 为什么这个巴特沃斯滤波器在 R 和 Matlab 中呈现不同的结果?
- c - 简单的 memcpy 实现 Segfaults
- android - 覆盖textview的文本大小
- cryptography - libgcrypt 如何为 CTR 模式增加计数器?
- javascript - VueJs / Laravel。不同对象中多个数组的总和
- transactions - 事务内部的过程调用