Input Tag Parameter Value in WebBrowser Control

I am trying to help a user log in to their account using a custom WebBrowser . I am trying to set the input tag value for the players username using the WebBrowser InvokeScript function. However, my current solution does nothing but make a blank white page.

My current code looks like this (web is the name for my WebBrowser ):

 web.Navigate(CurrentURL, null, @"<script type='text/javascript'> function SetPlayerData(input) { username.value = input; return true; } </script>"); web.Navigated += (o, e) => { web.IsScriptEnabled = true; web.InvokeScript("SetPlayerData", @"test"); }; 

As already mentioned, this is not working right now. I am trying to do this on a Windows Phone, so a number of examples that I found here and elsewhere will not work, since I do not have access to the same functions.

How can I accomplish this successfully?

EDIT: I may have been unclear, but I'm working with Windows Phone, which has a limited API available, as I don't have access to the Document property and a number of other functions. I have access to InvokeScript , but not much more.

+6
source share
1 answer
 webBrowser1.Document.GetElementById("navbar_username").InnerText ="Tester"; webBrowser1.Document.GetElementById("navbar_password").InnerText = "xxxxxxxxxxx"; foreach (HtmlElement HtmlElement1 in webBrowser1.Document.Body.All) { if (HtmlElement1.GetAttribute("value") == "Log in") { HtmlElement1.InvokeMember("click"); break; } } 

you can find here: http://deltahacker.gr/2011/08/15/ftiakste-to-diko-sas-robot/

+10
source

All Articles