jeudi 3 mai 2018

Trigger User Input Event When Changing Element Attribute In IE 11

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

My Setup :

C Sharp

Winforms

.NET 4.7.02556

Browser :

 webBrowser.WebBrowserShortcutsEnabled = true;
            webBrowser.ScriptErrorsSuppressed = false;

            Registry.SetValue(@"HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Internet Explorer\MAIN\FeatureControl\FEATURE_BROWSER_EMULATION",
               System.AppDomain.CurrentDomain.FriendlyName, 11000);

            Registry.SetValue(@"HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Internet Explorer\MAIN\FeatureControl\FEATURE_BROWSER_EMULATION",
              System.AppDomain.CurrentDomain.FriendlyName.Replace(".exe", ".vshost.exe"), 11000);

System.Windows.Forms.WebBrowser

Aucun commentaire:

Enregistrer un commentaire