Skip to content Skip to sidebar Skip to footer

How Do I Call The Click Function Of An Html Button Using The Class Name Of The Control Or Its Value But Not The Id?

I'm creating a WPF application that opens a WebBrowser instance and get the HTML code ... I was calling the elements by ID for example: if the HTML is:

Solution 1:

You have to use GetElementByTagName("INPUT") and then find your HtmlElement by its GetAttribute("class") method to invoke the click event.

var elems = wb.Document.GetElementByTagName("INPUT");

foreach(HtmlElement elem in elems){
    if(elem.GetAttribute("class") == "submit"){
        elem.InvokeMember("click");
    }
}

Post a Comment for "How Do I Call The Click Function Of An Html Button Using The Class Name Of The Control Or Its Value But Not The Id?"