c# - How can i click on a button in web page using webbrowser? -
the last div variable elementid working: "ctl00_rightmaincontent_submitaddress_p_submitbuttom"
the problem items1 variable part. want click button can see in screenshot it's marked. class name "addimg" , onclick openuploaddiv(0) not in div variable in bottom onclick openuploaddiv(0) can't find it's id. , tried add classname "addimg" in foreach didn't find it.
what want click automatic on addimg button.
void webbrowser4_documentcompleted(object sender, webbrowserdocumentcompletedeventargs e) { if (e.url.absoluteuri != webbrowser4.url.absoluteuri) { return; } htmlelementcollection items = webbrowser4.document.getelementsbytagname("div"); foreach (htmlelement item in items) { if (item.getattribute("classname") == "elements") { webbrowser4.document.getelementbyid("ctl00_rightmaincontent_txt_subject").innertext = "db החוקר מ סי.אס.איי"; } } htmlelementcollection items1 = webbrowser4.document.getelementsbytagname("div"); foreach (htmlelement item in items1) { if (item.getattribute("classname") == "elements") { // openuploaddiv(0); var div1 = webbrowser4.document.getelementbyid("file-input"); if (div1 != null) { var button = div1.all[0]; if (button != null) button.invokemember("click"); else messagebox.show("button not found."); } else { } } } var div = webbrowser4.document.getelementbyid("ctl00_rightmaincontent_submitaddress_p_submitbuttom"); if (div != null) { var button = div.all[0]; if (button != null) button.invokemember("click"); else messagebox.show("button not found."); } else { messagebox.show("div not found."); } }
and screenshot when did inspect element
Comments
Post a Comment