如何点击我的webbrowser上的这个按钮? (视觉基础)

时间:2015-05-26 12:01:41

标签: vb.net

我正在寻找代码来点击webbrowser上的那个按钮:

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

我试过了:

   For Each elem As HtmlElement In WebBrowser1.Document.GetElementsByTagName("a")
        If elem.GetAttribute("class") = "single_like_button btn3-wrap" Then
                elem.InvokeMember("click")
            End If

   For Each elem As HtmlElement In WebBrowser1.Document.GetElementsByTagName("div")
        If elem.GetAttribute("class") = "btn3" Then
                elem.InvokeMember("click")
            End If

For Each elem As HtmlElement In WebBrowser1.Document.GetElementsByTagName("div")
If elem.InnerText = "Subscribe" Then
elem.InvokeMember("click")
End If

For Each elem As HtmlElement In WebBrowser1.Document.GetElementsByTagName("a")
If elem.InnerText = "Subscribe" Then
elem.InvokeMember("click")
End If

没有一个正常工作。

1 个答案:

答案 0 :(得分:0)

在检查之前,使用FLAG_ACTIVITY_NO_HISTORY方法从Intent refresh = new Intent(context, context.getClass()); refresh.setFlags(Intent.FLAG_ACTIVITY_NO_HISTORY|Intent.FLAG_ACTIVITY_NO_ANIMATION); context.startActivity(refresh); 的两端删除空格:

Trim