我正在致力于将一些数据自动输入到 Intranet 网页中。过去,我曾成功使用此类代码单击复选框,但无法使其在扩展行的加号上工作。下面的代码什么也不做,也不提示错误,代码运行正常。
这是我的代码:
Set div = IE.document.getElementsByTagName("div")
For Each i In div
'showExpand?
If i.id Like "iconShowA*" Then
If i.onclick = "showExpand(*)" Then
i.Click'Click plus sign
v = Replace(i.id, "iconShowA", "")
col.Add v 'store the numeric part
End If
End If
Next i
For Each v In col
Debug.Print v
Next v
相关的 HTML 行是:
(我要点击的内容可能是可变数量的,具有不同的数字标识符“iconShowA(x)”)
<div id="iconShowA34" class="ui-icon ui-icon-plusthick" onclick="showExpand('34','34')" ;="" style="display: block;"></div>
(我也需要避免点击这些)
<div id="iconShowA_N4" class="ui-icon ui-icon-plusthick" onclick="showExpandSub('4','4')" ;=""></div>