C# 单击WebBrowser c中的图像#

C# 单击WebBrowser c中的图像#,c#,html,C#,Html,好的,我需要点击webBrowser1中的某个图像。目前我正在使用这段代码,但它似乎根本不起作用。没有任何错误。它运行,但不单击类项。它陷入了等待按钮的循环中 HtmlElementCollection classButton = webBrowser1.Document.All; bool found = true; foreach (HtmlElement element in classButt

好的,我需要点击webBrowser1中的某个图像。目前我正在使用这段代码,但它似乎根本不起作用。没有任何错误。它运行,但不单击类项。它陷入了等待按钮的循环中

                HtmlElementCollection classButton = webBrowser1.Document.All;
                bool found = true;
                foreach (HtmlElement element in classButton) 
                {
                    try
                    {       
                        if (element.GetAttribute("className") == "single_like_button btn3-wrap")
                            {
                                element.InvokeMember("click");
                                label1.Text = "Status : Doing Facebook";
                                ac += 1;
                                label2.Text = "Pages Done : " + ac.ToString();
                                strTester = "No";
                                Form2.viewed = "No";
                                while (Form2.viewed == "No")
                                {
                                    Application.DoEvents();
                                }
                                found = true;
                                popup.Close();
                            }
                            else if (element.GetAttribute("className") != "single_like_button btn3-wrap")
                            {
                                label1.Text = "Status : Waiting";
                                ac += 1;
                                found = true;
                                timer2.Interval = 5000;
                                timer2.Start();
                            }
                      }
                 }
正如你所看到的,我目前正在按类单击,它不工作,只是运行等待循环

网站的HTML代码

<a class="single_like_button btn3-wrap" onclick="openFbLWin_2350395();">
                                        <span>&nbsp;</span><div class="btn3">Like</div></a>

喜欢

我尝试使用invokescript方法来执行openFBLWin,但它的末尾总是有一个随机数

“它不起作用”不是一个问题陈述。这可以是任何东西——编译错误、运行时异常、意外行为。。。什么不起作用?具体点。好吧,我编辑了它,在顶部解释得更好一些。嗯。。这是一个使用web浏览器控件的win应用程序,对吗?这是正确的Brett这应该更有帮助。。它解释了如何使用windows.external.METHODNAME引用代码页方法