简体   繁体   English

InvokeMember不适用于WPF Webbrowser

[英]InvokeMember does not work with WPF Webbrowser

So I am having this issue with automating a webpage. 所以我在自动化网页时遇到了这个问题。 Here's some information: 这里是一些信息:

    private bool refreshing = true;
    private mshtml.HTMLDocument bcode;

    private void browser_LoadCompleted(object sender, System.Windows.Navigation.NavigationEventArgs e)
    {
        bcode = browser.Document as mshtml.HTMLDocument;

        if (refreshing)
        {
            bcode.getElementById("refreshPage").InvokeMember("click");
        }
    }

I am using mshtml and it is listed as a reference. 我正在使用mshtml,它被列为参考。 The error I am getting is: 我得到的错误是:

  'mshtml.IHTMLElement' does not contain a definition for 'InvokeMember' and no 
   extension method 'InvokeMember' accepting a first argument of type 
  'mshtml.IHTMLElement' could be found (are you missing a using directive or
   an assembly reference?)

I built the code of this ANSWER However I can't see why it works for him (supposedly) and not me. 我构建了此ANSWER的代码,但是我看不出它为什么对他有用(据说),而不对我有用。

Apologies if a dupe. 道歉,如果一个骗子。

Found the solution, 找到了解决方案,

HTMLDocument doc = (HTMLDocument)wb1.Document;
        IHTMLElement btn = doc.getElementById("refreshPage");
        if (btn !=null)
        {
            btn.click();
        }

Reference of mshtml. mshtml的参考。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM