VB.NET - Click Submit Button on Webbrowser page

前端 未结 8 684
时光说笑
时光说笑 2021-02-09 02:30

I have a html page open on my webbrowser object, I can enter username and password okay, but I\'m stuck and don\'t know how to submit the info. Here is the html code for the us

8条回答
  •  无人共我
    2021-02-09 03:00

    I am quite benefited with http://stackoverflow.com. I was wandering from hours for automatic login and submit from vb application to another web site. Due to help of this site I am able to complete my task

    I have to login following web php page.

    
    
    
    
    Username
    Password

    For automatic Login and clicking I wrote following VB.Net Code. In form1 I placed a button and a Webbrowser control

    Imports System.IO
    Imports System.Windows.Forms
    
    
    
    Public Class Form1
    
    
        Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
    
    
            WebBrowser1.Navigate("http://xyz.com")
    
    
    
        End Sub
    
        Private Sub WebBrowser1_DocumentCompleted(ByVal sender As Object, ByVal e As System.Windows.Forms.WebBrowserDocumentCompletedEventArgs) Handles WebBrowser1.DocumentCompleted
            WebBrowser1.Document.GetElementById("name").SetAttribute("Value", "bharatlal")
            WebBrowser1.Document.GetElementById("password").SetAttribute("Value", "mahato")
            WebBrowser1.Document.GetElementById("subimt").Focus()
            WebBrowser1.Document.GetElementById("subimt").InvokeMember("click")
        End Sub
    End Class
    

提交回复
热议问题