0
我試圖插入數據到搜索字段,然後單擊搜索按鈕。我試過getElementsByid("SiteSearchForm_SearchBtn")(0).Click
和getElementsByclassname("searchBtn")(0).Click
。網站上的搜索按鈕將不會單擊VBA
HTML:
<div class="searchBtn"><a href="#search" id="SiteSearchForm_SearchBtn">Search</a></div>
VBA代碼:
With IE
.Visible = True
.Navigate URL_1
Do Until .ReadyState = 4
DoEvents
Loop
Application.Wait (Now + TimeValue("0:00:02"))
IE.Document.getelementsbyclassname("hint hint-search")(0).Value = "Eliroyal2$"
IE.Document.getElementsByid("SiteSearchForm_SearchBtn")(0).submit
Application.Wait (Now + TimeValue("0:00:10"))
End With
將0放在方括號中,並按類別嘗試獲取元素。「(」hint hint_search「)[0]'並且第四次編輯的元素不爲零。 getElementById並創建I資本 – Billy