输入标记InvokeMember("Click")未在Web浏览器中触发onclick事件

sum*_*mer 6 c# browser onclick recaptcha

我使用Dotnet Web浏览器单击输入元素 - 按钮.触发此click事件时,它会执行JS函数,该函数使用Google Recaptcher生成验证码,其来源类似于Recaptcha链接.现在的问题是我无法触发onClick事件,我使用以下代码:

HtmlElementCollection inputColl = HTMLDoc.GetElementsByTagName("input");
        foreach (HtmlElement inputTag in inputColl)
        {
            string valueAttribute = inputTag.GetAttribute("value");
            if (valueAttribute.ToLower() == "sign up")
            {
                inputTag.Focus();
                inputTag.InvokeMember("Click");
                break;
            }
        }
Run Code Online (Sandbox Code Playgroud)

我检查了一切,我正在捕捉正确的按钮,但不知道为什么onClick事件没有被解雇.任何建议都是受欢迎的.

小智 4

  1. 添加对 Microsoft.mshtml 的引用;
  2. 看下面的固定示例:

        HtmlElementCollection inputColl = HTMLDoc.GetElementsByTagName("input");
        foreach (HtmlElement inputTag in inputColl)
        {
            string valueAttribute = inputTag.GetAttribute("value");
            if (valueAttribute.ToLower() == "sign up")
            {
                inputTag.Focus();
                IHTMLElement nativeElement = el.DomElement as IHTMLElement;
                nativeElement.click();
                break;
            }
        }
    
    Run Code Online (Sandbox Code Playgroud)