R
R
rfvgy2020-06-02 00:55:47
Visual Basic
rfvgy, 2020-06-02 00:55:47

How to programmatically fill out a form on a website?

On the site b98300b7.beget.tech, I posted a form that records the data entered in 2 text fields - login and password. (Later I will delete this form). I need to let's say that by pressing a button (on a form in my program) data were entered into these 2 fields on the site and the "Login" button was pressed.
Please do not post links to other similar topics, it is not very clear there.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
R
rfvgy, 2020-06-03
@rfvgy

I actually found the answer to my own question:

Private Sub Button5_Click(sender As Object, e As EventArgs) Handles Button5.Click
        Dim AuthThread As New System.Threading.Thread(AddressOf DataAuth)
        AuthThread.IsBackground = True
        AuthThread.Start()
    End Sub
    Sub DataAuth()
        Invoke(Sub() WebBrowser1.Document.GetElementById("id_username").InnerText = "Login")
        Threading.Thread.Sleep(50)
        Invoke(Sub() WebBrowser1.Document.GetElementById("id_password").InnerText = "Password")
        Threading.Thread.Sleep(300)
        Invoke(Sub()
                   Dim buttons As HtmlElementCollection = WebBrowser1.Document.GetElementsByTagName("input")
                   For Each btn As HtmlElement In buttons
                       If btn.GetAttribute("classname") = "button-green" Then
                           btn.InvokeMember("Click")
                       End If
                   Next
               End Sub)
    End Sub

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question