jeudi 3 mai 2018

a better way to update HtmlElement value in WebBrowser Control

Im working on a simple internet bot that requires repeatedly sending input to the web from multiaple browsers. I seem to have a problem making the web detect that an input has been written in the TextBox when changing the attribute of the TextBox element. Here Is the problematic part of the code :

webBrowser.Document.GetElementById("inputSession").SetAttribute("value" , "TEST ");
        webBrowser.Document.GetElementById("inputSession").Focus();
        SendKeys.SendWait("  ");

Right now im using the SendKeys.SendWait(" "); Method with the HtmlElement.Focus() method and its working perfectly for one visble browser

The problem starts when i make the browser invisble. The SendKeys.SendWait(" "); Method will simply not send input to that TextBox resulting in the web saying something like " You Must Fill This Part Before You Can Finish" i assume it is a result of the web not registering that there was a user input there.

if i simply do

 webBrowser.Document.GetElementById("inputSession").SetAttribute("value","TEST ");

the web will give the "You Must Fill This Part Before You Can Finish" massage when i click the enter button, even when i can clearly see the input in the textbox. mean that there is some kind of user input event that i need to trigger. What i need is a better way to make the web realize there is input in the textbox




Aucun commentaire:

Enregistrer un commentaire