Donate

WPF Webbrowser Loop Through Html Elements And Submit

A question was raised on vbforums on how to invoke click a button using WPF webbrowser control. This sample loads google.com page and writes a sample text on the textbox and then invoking the click button.
HTMLDocument document = (HTMLDocument)wbGetHost.Document;  
       foreach (IHTMLElement myelem in document.getElementsByTagName("input"))  
       {  
         if (myelem.id != null)  
         {  
           if (myelem.id.Equals("lst-ib") && myelem.className.Equals("lst lst-tbb") && !document.documentElement.innerHTML.ToLower().Contains("wikipedia"))  
           {  
             HTMLInputElement el = myelem as HTMLInputElement;  
             el.value = "Bill Gates";  
             HTMLInputElement searchButton = (HTMLInputElement)document.all.item("btnK", 0);  
             searchButton.click();  
             break;  
           }  
         }  
       } 
Greg

Comments

Donate

Popular Posts From This Blog

WPF CRUD Application Using DataGrid, MVVM Pattern, Entity Framework, And C#.NET

How To Insert Or Add Emojis In Microsoft Teams Status Message

TypeScript Error Or Bug: The term 'tsc' is not recognized as the name of a cmdlet, function, script file, or operable program.