【发布时间】:2021-02-11 12:37:46
【问题描述】:
在一个网站上我能够登录,然后我试图从下拉菜单中选择一个值,但我无法获得包含该菜单的任何对象。
令人担忧的是该页面似乎正在使用三个框架窗口 - 下拉菜单位于其中一个窗口上。
<label for="edit-multiple-form">...</label>
<select id="edit-multiple-form" name="NNN" class="form-select form-control required ajax-processed"> == $0
<option value selected="selected">- Select -</option>
<option value="1"> OPTION1 </option>
<option value="2"> OPTION2 </option>
<option value="3"> OPTION3 </option>
</select>
::after
</div>
VBA 代码(更新):
Sub LogIn()
' ' ' ' '
'when Error
On Error GoTo Err_Clear
' ' ' ' '
'New HTML Document for the page
Dim IE3 As HTMLDocument
Set IE3 = IEBrowser.document
Dim elemSelect As IHTMLElement
Dim elemOption As IHTMLElement
Set elmSelect = IE3.getElementById("edit-multiple-wallet-form")
Debug.Print elemSelect.innerText
Set elemOption = elemSelect.getElementByTagName("option") '@@ it gives me an error
If elemOption.Length > 0 Then
Dim i, text
For i = 0 To elemOption.lengh - 1
text = text & elemOption.Item(i).innerText
Next
MsgBox "All pre elements text: " & text
End If
' ' ' ' '
Err_Clear:
If Err <> 0 Then
Err.Clear
Resume Next
End If
End Sub
================================================ ======================
'Got a new HTML document after log on the the first page
Dim IE3 As HTMLDocument
Set IE3 = IEBrower.document
'then tried several methods to get the object using the following commands
IE3.document.querySelector("option")
IE3.all.NNN.value 'NNN is the name of the dropdown menu object
IE3.getElementsByID("edit-multiple-form)
IE3.getElementsByClass("form-select form-control required ajaz-processed")
================================================ =============================
我能够抓取下拉菜单对象,但在 @@ 处仍然出现错误 它有什么问题? 任何帮助将不胜感激。
【问题讨论】:
标签: vba parsing dropdown frame