我已經搜索並搜索了代碼,我嘗試過的所有東西都不起作用。 基本上我所需要的web瀏覽器運行測試代碼之前完全加載...等到WebBrowser加載? (VB 2010)
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
WebBrowser1.Document.GetElementById("login").SetAttribute("value", TextBox1.Text)
WebBrowser1.Document.GetElementById("passwd").SetAttribute("value", TextBox2.Text)
WebBrowser1.Document.GetElementById("SI").InvokeMember("Click")
Where I need to insert the WaitForPageLoad()
RichTextBox1.Text = WebBrowser1.DocumentText
If InStr(RichTextBox1.Text, "To continue, create an Xbox profile") Then
MsgBox("You do not have an xbox account associated with this gamertag, please log into xbox.com with the account then create an xbox profile.")
Else
MsgBox("nothing")
End If
正如你可以看到我試圖用一個腳本來讓我登錄到Xbox.com,和它的工作,但只是一點點。這段代碼的過程太快,不檢查字符串說:「要繼續......」權源代碼,基本上
WebBrowser1.Document.GetElementById("login").SetAttribute("value", TextBox1.Text)
WebBrowser1.Document.GetElementById("passwd").SetAttribute("value", TextBox2.Text)
WebBrowser1.Document.GetElementById("SI").InvokeMember("Click")
它確實是點擊,發出滴答聲,做的按鈕後登錄過程中,但它必須加載一個全新的頁面,問題在於它執行下一行代碼的速度太快,下一行代碼在錯誤的源代碼中搜索該字符串。我需要它來等待頁面加載,然後運行該行
RichTextBox1.Text = WebBrowser1.DocumentText
哪個拷貝網頁瀏覽器的源代碼,其隨後被搜索的字符串文本框。我已經嘗試了一切。我覺得WaitForPageLoad()會很好,但是我得到一個錯誤,告訴我它沒有被聲明。誰能幫忙?
如果我明白你的問題,和林不知道我這樣做,我認爲你正在尋找webbrowser.DocumentCompleted事件。你只是想把你的代碼移動到回調事件中,並且它會在你的文檔被完全加載時執行。請注意,如果其他文檔由您的網頁加載,它可以多次啓動。 –