2014-03-27 32 views
0

我想在VB.NET中創建一個應用程序,該應用程序將登錄到特定的站點,到目前爲止這工作,但我想知道在那裏登錄後,在Internet Explorer的新頁面中形成類似的功能。到目前爲止我的代碼是:VB.net提交登錄按鈕後,在新頁面中執行操作

Dim ie As Object 
    ie = CreateObject("internetexplorer.application") 
    ie.Navigate("http://forums.macrumors.com/") 
    ie.Visible = True 
    While Not ie.ReadyState = WebBrowserReadyState.Complete 
     Application.DoEvents() 
    End While 
    If ie.Document IsNot Nothing Then 
     ie.Document.All("vb_login_username").SetAttribute("value", "user-name-here") 
     ie.Document.All("vb_login_password").SetAttribute("value", "Password-here") 
     ie.Document.getElementsByTagName("input").item(20).Click() 
    End If 

這個代碼讓我登陸,但我想執行類似的任務,一旦我達到一個新的頁面,任何提示?

+0

你是什麼意思',形成在互聯網Explore'達到了新的一頁類似功能的意思是,你有什麼要完成?請澄清你的問題,它有點混亂。 – Dayan

+0

我正在使用vb.net以我提供的用戶名/密碼登錄到特定的網頁,然後在特定的輸入框中輸入某個按鈕並點擊提交按鈕。 – user1186472

回答

0

如果您打算對此邏輯進行硬編碼,您需要瀏覽DOM並找到您登錄後指向的特定輸入框的element id

例如

WebBrowser1.Document.Forms[0].All["textField"].SetAttribute("value", "hello world"); 
WebBrowser1.Document.GetElementById("btn_login").Focus(); 
WebBrowser1.Document.GetElementById("btn_login").InvokeMember("submit") 
+0

但我如何刷新DOM對象,以便它在我登錄後反映頁面 – user1186472