Can you please tell me how to click buttons on the site programmatically through the webbrowser component?
1 answer
var elements = webBrowser1.Document.GetElementsByTagName("input"); foreach (HtmlElement element in elements) { string attrValue = element.getAttribute("value"); if (attrValue == "Купить") { element.InvokeMember("click"); } } - It does not work; (I made a button that clicking on it would press a button on the site, press a button, nothing happens - Pyrejkee
- Guys, help, still did not understand. - Pyrejkee
- @KirillKiryanchikov It's time for you to upload your code. "made a button ... press a button" - can mean anything. Specify at least a link to the page you are trying to manage. - Igor
- On the form of the component is a web browser and my button, I want to click on my button - click the button on the site. I can’t do it
private void button1_Click(object sender, EventArgs e) { var elements = webBrowser1.Document.GetElementsByTagName("input"); foreach (HtmlElement element in elements) { if (element.GetAttribute("value") == "Купить") { element.InvokeMember("click"); } } }- Pyrejkee - Put the breakpoint on the line with
var elements = ..., and goattrValue(F10) looking at the value ofattrValue. - Igor
|
webBrowser1.Document.GetElementById("buttonId").InvokeMember("click");- IgorwebBrowser1.Document.GetElementById("Купить").InvokeMember("click");- Pyrejkeeidattribute.<button type="submit" id="btnBuy">Купить</button>- Igor