【发布时间】:2017-06-26 19:24:45
【问题描述】:
我正在尝试检查网站上的复选框。
复选框 HTML:
<input name="ApplicationSearchGroupsSelect_0" title='Select "Basic Access - Computer Logon"' type="checkbox" value="1">
复选框上方的 HTML:
<form name="main" id="main" onkeypress="return imOnKeyPress(event)" action="?facesViewId=/app/page/screen/standard_search.jsp" method="post">
代码:
Set objinputs = aExplorer.document.getElementsByTagName("form")
For Each ele In objinputs
If ele.Name Like "ApplicationSearchGroupsSelect_0" And ele.Title Like "Select "Basic Access - Computer Logon"" Then
ele.Focus
ele.Click
ele.Selected = True
ele.Checked = True
ele.FireEvent "onkeypress"
End If
Next
Do While aExplorer.Busy
Application.Wait DateAdd("s", 1, Now)
Loop
aExplorer.document.getElementById("main").FireEvent ("onkeypress")
Do While aExplorer.Busy
Application.Wait DateAdd("s", 1, Now)
Loop
当我尝试运行此代码时没有任何反应(没有错误消息,代码完成运行并且没有检查任何内容)。除了触发 javascript 事件之外,尝试单击按钮,选中复选框,使 selected=true,我不知道如何单击此复选框,并且数小时的网络搜索没有返回任何内容。我也尝试将值更改为 0,1,2,但没有任何反应。
关于如何检查我尝试过的复选框之外的任何想法?谢谢!
【问题讨论】:
-
我认为
And ele.Title Like "Select "Basic Access - Computer Logon""甚至不会编译。字符串中的双引号需要通过将两个双引号放在一行中来进行转义,如下所示:And ele.Title Like "Select ""Basic Access - Computer Logon""" Then -
设置 objinputs = aExplorer.document.getElementsByTagName("input")
标签: html excel vba internet-explorer checkbox