How to click a button on an ASP.NET web page programmatically?

前端 未结 9 1373
既然无缘
既然无缘 2021-02-09 10:06

I am trying to figure out how to click a button on a web page programmatically.

Specifically, I have a WinForm with a WebBrowser control. Once it navigates to the targe

9条回答
  •  挽巷
    挽巷 (楼主)
    2021-02-09 10:43

    How does this work? Works for me

    HtmlDocument doc = webBrowser1.Document;
    
    doc.All["userIDTextBox"].SetAttribute("Value", "user1");
    doc.All["userPasswordTextBox"].SetAttribute("Value", "Password!");
    doc.All["logonButton"].InvokeMember("Click");
    

提交回复
热议问题