我正在尝试创建一个脚本来导航到网页,等待元素加载,然后从新页面收集元素。就目前而言,这个脚本在它应该等待的时候直接运行:
Do Until AxWebBrowser1.ReadyState = WebBrowserReadyState.Complete
处理后:
htmldoc.getElementsByName("GetCase").item(0).click() 'click the submit button
我立即得到第二个子的消息框弹出窗口,而实际上页面还没有完成加载。我该如何解决这个问题并让脚本等到页面准备好,然后制作 htmldoc = axwebbrowser1.document
Private Sub GetCase()
htmldoc = AxWebBrowser1.Document.frames("top").document 'set the top frame to be searched for
setval = htmldoc.getElementsByName("caseNum").item(0) 'grab the input name for contracts
setval.value = TextBox1.Text 'set the textbox value into the web form input
TextBox1.Clear()
htmldoc.getElementsByName("GetCase").item(0).click() 'click the submit button
Do Until AxWebBrowser1.ReadyState = WebBrowserReadyState.Complete 'do events until it is complete
Application.DoEvents()
Loop
If ComboBox1.Text = "MM" Then
Gather()
End If
End Sub
Private Sub Gather()
Do Until AxWebBrowser1.ReadyState = WebBrowserReadyState.Complete 'do events until it is complete
Application.DoEvents()
Loop
htmldoc = AxWebBrowser1.Document
MessageBox.Show("got elements")
End Sub