Well this script is working partially, when the script submit the login a MsgBox("The login is wrong!") appeared, but when the page load a MsgBox("The login is ok!") appears.
Why the "The login is wrong!" is appearing? Can someone fix for me or tell me another way to do that?

Private Sub WebBrowser1_DocumentCompleted(ByVal sender As System.Object, ByVal e As System.Windows.Forms.WebBrowserDocumentCompletedEventArgs) Handles WebBrowser1.DocumentCompleted
        If WebBrowser1.Url.AbsoluteUri = "https://steamcommunity.com/login/" Then
            WebBrowser1.Document.GetElementById("steamAccountName").SetAttribute("Value", "gogost")
            WebBrowser1.Document.GetElementById("steamPassword").SetAttribute("Value", "gogost")
            WebBrowser1.Document.Forms(1).InvokeMember("submit")


        End If


        If Me.WebBrowser1.DocumentText.Contains("LogOut") Then

            MsgBox("The login is ok!")

        Else

            MsgBox("The login is wrong!")

        End If

Edited 6 Years Ago by SaaDwTk: n/a

...Why the "The login is wrong!" is appearing?...

The reason is because you are not logged in when you first load that web-page.

See if this helps about checking if you have already attempted to Log In.

Private websiteAlreadyAccessed As Boolean = False '// determine if webpage has been accessed.

    Private Sub WebBrowser1_DocumentCompleted(ByVal sender As System.Object, ByVal e As System.Windows.Forms.WebBrowserDocumentCompletedEventArgs) Handles WebBrowser1.DocumentCompleted
        If WebBrowser1.Url.AbsoluteUri = "https://steamcommunity.com/login/" Then
            WebBrowser1.Document.GetElementById("steamAccountName").SetAttribute("Value", "gogost")
            WebBrowser1.Document.GetElementById("steamPassword").SetAttribute("Value", "gogost")
            WebBrowser1.Document.Forms(1).InvokeMember("submit")
        End If

        If Me.WebBrowser1.DocumentText.Contains("LogOut") Then
            MsgBox("The login is ok!")
        Else
            '// check if web-page has been visited and display result if there was already an attempt to LogIn.
            If websiteAlreadyAccessed = True Then MsgBox("The login is wrong!")
        End If
        websiteAlreadyAccessed = True '// set to True once first loading the web-page.
    End Sub
This question has already been answered. Start a new discussion instead.