sgaggerj
asked on
VB.Net setting input fields on web page
Hi Experts,
i'm trying to interact with a web-page through my app using vb.net / vs2008.
i have a webbrowser control on my form and the page i need to interact with is loaded there (in this case, http://www.fedex.com/us/)
I am trying to set the username and password fields, but cannot find how to access them.
i would also need to click the login button, or trigger the submit.
i have tried various iterations of
WebBrowser1.Document.GetEl ementByID and .GetElementByTagName to no avail.
Help?
i'm trying to interact with a web-page through my app using vb.net / vs2008.
i have a webbrowser control on my form and the page i need to interact with is loaded there (in this case, http://www.fedex.com/us/)
I am trying to set the username and password fields, but cannot find how to access them.
i would also need to click the login button, or trigger the submit.
i have tried various iterations of
WebBrowser1.Document.GetEl
Help?
ASKER
i'm running this code in the Navigated event handler of WebBrowser1 (which should mean it's fully loaded right?)
i had tried using
Dim u as HtmlElement = WebBrowser1.Document.GetEl ementById( "username" )
and was always coming up with 'nothing' as the value of u. (still am)
my IE is IE8, but i don't think that should matter.
i had tried using
Dim u as HtmlElement = WebBrowser1.Document.GetEl
and was always coming up with 'nothing' as the value of u. (still am)
my IE is IE8, but i don't think that should matter.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
I'll try that then when I get back in the office. My fault I didn't look closer at the API.
ASKER
Yep, that was what I was doing wrong.
Any suggestions on "clicking"
i've tried
WebBrowser1.Document.GetEl ementById( "login").I nvokeMembe r("click")
and
WebBrowser1.Document.GetEl ementById( "logonForm ").invokeM ember("sub mit")
and
WebBrowser1.Document.Forms .Item("log onForm").I nvokeMembe r("submit" )
the "click" doesn't do anything
the "submit" both give a 405 error.
any suggestions?
Any suggestions on "clicking"
i've tried
WebBrowser1.Document.GetEl
and
WebBrowser1.Document.GetEl
and
WebBrowser1.Document.Forms
the "click" doesn't do anything
the "submit" both give a 405 error.
any suggestions?
Nope, no idea there I'm sorry.
ASKER
Ok, seems I got it working using an idea from
http://www.vbforums.com/showthread.php?p=2618114#post2618114
For Each ele As HtmlElement In WebBrowser1.Document.GetEl ementsByTa gName("inp ut")
If ele.Name = "login" Then
ele.InvokeMember("click")
End If
Next
now, why the above didn't work i have no idea.
http://www.vbforums.com/showthread.php?p=2618114#post2618114
For Each ele As HtmlElement In WebBrowser1.Document.GetEl
If ele.Name = "login" Then
ele.InvokeMember("click")
End If
Next
now, why the above didn't work i have no idea.
ASKER
webtubbs should get all 500 points. I didn't mean to close it w/ no points.
Ahh, there's actually 2 elements named "login". The first one (which was returned with the single line code) is actually a DIV, so invoking the click on it would do nothing.
Wayne
Wayne
Sorry, but I have to object to how you are closing this question. I answered the original question as asked. The clicking problem was a subsequent query and not mentioned until after your original question was solved.
ASKER
@WallyMod
Thank you
@webtubbs
Sorry about that, i posted right away that you should get all 500 points, and am glad to see you did.
(the clicking was part of the original question though)
Thanks again for your help.
Thank you
@webtubbs
Sorry about that, i posted right away that you should get all 500 points, and am glad to see you did.
(the clicking was part of the original question though)
Thanks again for your help.
WebBrowser1.Document.GetEl
WebBrowser1.Document.GetEl
Where are you trying to set these fields? Could it be that the page has not fully loaded?
Wayne