Answered by:
Click a form button inside webbrowser

Question
-
Hi all.
I am trying to extract data from some web page, using webbrowser control, but first i have to login. I would like to login automaticly.
On my web page, as you allready know, I have username and passwor fields that i can fill using following code:
What i dont know is how to perform a click to the submit button. This is its html code:
<INPUT TYPE="SUBMIT" VALUE="SEND" NAME="PRIJAVA">
This code doesnt work:
wBrowser.Document.Forms(0).InvokeMember("submit")
nor
wBrowser.Document.Forms(0).InvokeMember("PRIJAVA")
I have a working code:
m_document =
Me.WebBrowser1.Document Dim user As MSHTML.HTMLInputElement = Nothing Dim password As MSHTML.HTMLInputElement = Nothing Dim login As MSHTML.HTMLInputElement = Nothing Dim usercounter As Boolean = Trueuser = element.DomElement
usercounter =
False End If ElseIf element.Name = "SIFRA" Thenpassword = element.DomElement
ElseIf element.Name = "PRIJAVA" Thenlogin = element.DomElement
End If Next elementuser.value =
"user123"password.value =
"pass123"login.click()
But it uses MSHTML that i cant use later in compact framework.
Is there any other (easier) way to do this ?
Something like ...
Me.WebBrowser1.Document.Forms(0).GetElementsByTagName("INPUT").Item(1).PerformClick
Saturday, September 2, 2006 6:23 PM
Answers
-
take a look at this too:
http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=967938&SiteID=1
Thursday, November 30, 2006 1:33 PMModerator
All replies
-
There may be a better way!
However, when faced with a similar problem I used an SSL secured web service to -
1. Authenticate the user with the current app credentials
2. Return a one time use security token (with limited lifetime validity specified in milliseconds)
3. Passed that token as a parameter to the login page
4. The login page checked for the token parameter
5. Retrieved the associated user
6. Deleted the one time use key
7. Authenticated browser based on appropriate user
Rgds
Sunday, September 3, 2006 3:23 AM -
In a simple case when "login" element only submits the form you can use:
Me.WebBrowser1.Document.Forms(0).submitThursday, November 30, 2006 11:09 AM -
take a look at this too:
http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=967938&SiteID=1
Thursday, November 30, 2006 1:33 PMModerator