vb.net - Submit button on web browser with html element -
okay, website http://dogwars.com/app/
i'm making app can login , stuff.
but login button on website:
<div style="margin-left: 77px; margin-top: 20px; height: 40px;"> <a href="#" onclick="document.getelementbyid('loginform').submit();" class="button"><span>login</span></a> </div>
for automatic submit button on vb.net use this:
if curelement.getattribute("onclick").equals("document.getelementbyid('loginform').submit();") curelement.invokemember("click") end if
but not log in automatically , i'm puzzled why doesn't..?
could me out? here full code:
public class form1 private sub button2_click(byval sender system.object, byval e system.eventargs) handles button2.click webbrowser1.navigate("http://dogwars.com/app/") end sub private sub webbrowser1_documentcompleted(byval sender system.object, byval e system.windows.forms.webbrowserdocumentcompletedeventargs) handles webbrowser1.documentcompleted dim theelementcollection htmlelementcollection = webbrowser1.document.getelementsbytagname("input") each curelement htmlelement in theelementcollection dim controlname string = curelement.getattribute("name").tostring if controlname = "email" curelement.setattribute("value", textbox1.text) elseif controlname = "password" curelement.setattribute("value", textbox2.text) end if next theelementcollection = webbrowser1.document.getelementsbytagname("input") each curelement htmlelement in theelementcollection if curelement.getattribute("onclick").equals("document.getelementbyid('loginform').submit();") curelement.invokemember("click") end if next end sub private sub form1_load(byval sender system.object, byval e system.eventargs) handles mybase.load end sub end class
you on complicating things html elements. here's should do:
webbrowser1.navigate("http://dogwars.com/app/") until webbrowser1.readystate = webbrowserreadystate.complete application.doevents() loop webbrowser1.document.getelementbyid("email").setattribute("value",textbox1.text()) webbrowser1.document.getelementbyid("password").setattribute("value",textbox2.text()) webbrowser1.document.getelementbyid("submit").invokemember("click")
that should work haven't tested though.
Comments
Post a Comment