2012-06-14 48 views
0

我正在做一个网站登录,我有问题检查,如果登录成功,因为我已经使用完成的文件。当我检查注销按钮是否存在时,该页面尚未完成加载。 这里是我的代码:登录Vb.net与浏览器

Imports System.Net 
Imports System.Text 
Imports System.IO 

Public Class Form1 

    Private Sub FutureButton2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles FutureButton2.Click 
     If TextBox1.Text = ("") Or 
      TextBox2.Text = ("") Or 
      TextBox3.Text = ("") Or 
      TextBox4.Text = ("") Or 
      TextBox5.Text = ("") Or 
      TextBox6.Text = ("") Then 
      MsgBox("some information is Missing please Fill all The Boxes") 

     Else 

      WebBrowser1.Navigate("http://combatarms.nexon.net/Support/UserAbuse.aspx") 
      Form2.Show() 

     End If 

    End Sub 
    Private Sub WebBrowser2_DocumentCompleted(ByVal sender As System.Object, ByVal e As System.Windows.Forms.WebBrowserDocumentCompletedEventArgs) Handles WebBrowser1.DocumentCompleted 


     Dim Username, Password As String 
     Username = TextBox1.Text 
     Password = TextBox2.Text 
     Form2.FutureProgressBar1.Progress = 10 
     On Error Resume Next 
     WebBrowser1.Document.All("userID").SetAttribute("value", TextBox1.Text) 
     Form2.FutureProgressBar1.Progress = 20 
     WebBrowser1.Document.All("password").SetAttribute("value", TextBox2.Text) 
     Form2.FutureProgressBar1.Progress = 30 
     WebBrowser1.Document.All("gnt_login_submit").InvokeMember("click") 
     Form2.FutureProgressBar1.Progress = 40 

     If WebBrowser1.StatusText = ("Done") Then 

      If (WebBrowser1.Document.All("btnLogin") Is Nothing) Then 
     msgbox("Works") 
      else 
     MsgBox("wrong") 

I have worked on it for days. The login is working but I can't get it to verify it. 

Thanks for the help! 

回答

0

编辑:

使用这一个:

Do While wb.ReadyState <> WebBrowserReadyState.Complete 
    Application.DoEvents() 

Loop 
+0

我想你没有得到我的观点......在登录后,该功能不允许页面完全加载 –

+0

您可以等到页面完成时按下Do :) – nnm