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
Originally Posted by tynab
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
Originally Posted by Hassan
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
Originally Posted by tynab
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.
Originally Posted by Hassan
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 ?
Originally Posted by tynab
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.
Originally Posted by Hassan
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 !
Originally Posted by tynab
Tnx , i changed something and now it works , tnx !