C# How to Click Button automatically via WebBrowser

后端 未结 5 2118
隐瞒了意图╮
隐瞒了意图╮ 2020-12-05 08:19

The Html code of my click page is :



        
5条回答
  •  无人及你
    2020-12-05 08:53

    Are you waiting for the page to load first? You should bind a function in your code to wait for the page to load, them click the button:

    static void form1_Load() {
        // ...
        webBrowser1.onDocumentReady += webBrowser_DocumentReady;
    }
    
    static void webBrowser1_DocumentReady() {
        webBrowser1.Document.GetElementById("publishButton-ns").InvokeMember("Click");
    }
    

提交回复
热议问题