我已经搜索并搜索了代码,我尝试过的所有东西都不起作用。 基本上我所需要的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事件。你只是想把你的代码移动到回调事件中,并且它会在你的文档被完全加载时执行。请注意,如果其他文档由您的网页加载,它可以多次启动。 –