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

前端 未结 9 1562
梦谈多话
梦谈多话 2021-02-09 09:57

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");
    

提交回复
热议问题