SolvedLog In System

Posts 1–8 of 8 · Page 1 of 1
Log In System
Code:
Code:
   WebBrowser1.Document.GetElementById("vb_login_username").SetAttribute("value", TextBox2.Text)
        WebBrowser1.Document.GetElementById("vb_login_password").SetAttribute("value", TextBox3.Text)
        WebBrowser1.Document.GetElementById("submit").InvokeMember("click")
Code:
Code:
WebBrowser1.Navigate("somesite/forum")
I need help wit log in button :
Code:

Code:
 WebBrowser1.Document.GetElementById("submit").InvokeMember("click")
submit (thats log in button ) is not working so i need little help here


Hassan's Edit: Advertisement Removed
Quote Originally Posted by tynab View Post
bump need help
On WebBrowser's DocumentComplete Event, add the following code:

Code:
For Each Element As HtmlElement In WebBrowser1.Document.GetElementsByTagName("form")
            For Each NestedElement As HtmlElement In Element.GetElementsByTagName("input")
                If NestedElement.OuterHtml.Contains("vb_login_username") Then
                    NestedElement.SetAttribute(NestedElement.Name, TextBox2.Text)
                End If
                If NestedElement.OuterHtml.Contains("vb_login_password") Then
                    NestedElement.SetAttribute(NestedElement.Name, TextBox3.Text)
                End If
                If NestedElement.OuterHtml.Contains("type=submit") Then
                    NestedElement.InvokeMember("click")
                    Exit For
                End If
            Next
        Next
Also, be sure to suppress error messages of the webpage by adding the following line on form's load event or before you navigate to the forum's url:

Code:
WebBrowser1.ScriptErrorsSuppressed = True
Quote Originally Posted by Hassan View Post


On WebBrowser's DocumentComplete Event, add the following code:

Code:
For Each Element As HtmlElement In WebBrowser1.Document.GetElementsByTagName("form")
            For Each NestedElement As HtmlElement In Element.GetElementsByTagName("input")
                If NestedElement.OuterHtml.Contains("vb_login_username") Then
                    NestedElement.SetAttribute(NestedElement.Name, TextBox2.Text)
                End If
                If NestedElement.OuterHtml.Contains("vb_login_password") Then
                    NestedElement.SetAttribute(NestedElement.Name, TextBox3.Text)
                End If
                If NestedElement.OuterHtml.Contains("type=submit") Then
                    NestedElement.InvokeMember("click")
                    Exit For
                End If
            Next
        Next
Also, be sure to suppress error messages of the webpage by adding the following line on form's load event or before you navigate to the forum's url:

Code:
WebBrowser1.ScriptErrorsSuppressed = True
Tnx but it works only like this
Code:
 For Each Element As HtmlElement In WebBrowser1.Document.GetElementsByTagName("form")
            For Each NestedElement As HtmlElement In Element.GetElementsByTagName("input")
                WebBrowser1.Document.GetElementById("vb_login_username").SetAttribute("value", TextBox1.Text)
                WebBrowser1.Document.GetElementById("vb_login_password").SetAttribute("value", TextBox2.Text)
                If NestedElement.OuterHtml.Contains("type=submit") Then
                    NestedElement.InvokeMember("click")
                    Exit For
                End If
            Next
        Next
        WebBrowser1.ScriptErrorsSuppressed = True
Quote Originally Posted by tynab View Post
Tnx but it works only like this
Code:
 For Each Element As HtmlElement In WebBrowser1.Document.GetElementsByTagName("form")
            For Each NestedElement As HtmlElement In Element.GetElementsByTagName("input")
                WebBrowser1.Document.GetElementById("vb_login_username").SetAttribute("value", TextBox1.Text)
                WebBrowser1.Document.GetElementById("vb_login_password").SetAttribute("value", TextBox2.Text)
                If NestedElement.OuterHtml.Contains("type=submit") Then
                    NestedElement.InvokeMember("click")
                    Exit For
                End If
            Next
        Next
        WebBrowser1.ScriptErrorsSuppressed = True
Yeah, haven't done anything browser related in a while so forgot the way it is done.

Anyways, marked solved. No more posting.
Quote Originally Posted by Hassan View Post


Yeah, haven't done anything browser related in a while so forgot the way it is done.

Anyways, marked solved. No more posting.
how to put now when someone log in correctly then something happens ?
Quote Originally Posted by tynab View Post
how to put now when someone log in correctly then something happens ?
You need to put a check on Browser's DocumentLoad event that if the page source contains some kind of greeting, then it means you are logged in.

E.g:

Code:
If WebBrowser1.DocumentText.Contains("Hello Username") Then
'Logged In. Do some stuff here...
Else
'Haven't Logged In !'
End If
You need to replace Hello Username with something that validates that the user has logged in.
Quote Originally Posted by Hassan View Post


You need to put a check on Browser's DocumentLoad event that if the page source contains some kind of greeting, then it means you are logged in.

E.g:

Code:
If WebBrowser1.DocumentText.Contains("Hello Username") Then
'Logged In. Do some stuff here...
Else
'Haven't Logged In !'
End If
You need to replace Hello Username with something that validates that the user has logged in.
Tnx , i changed something and now it works , tnx !
Quote Originally Posted by tynab View Post
Tnx , i changed something and now it works , tnx !
No problem.
Posts 1–8 of 8 · Page 1 of 1

Post a Reply

Similar Threads

Tags for this Thread

None

Need help?