2012-06-14 212 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