0

我正在使用 Visual Studio 2005 Visual Basic Windows 应用程序。我需要找到一个按钮并从后面的代码中单击它。但是按钮没有名称,也没有 id。

当我看到网页按钮的来源是这样的;

<input type="submit" value="Devam Et" onclick="return validatee();" style="background:#F79F81;font-weight:bold">

我正在尝试像这样使用 .outerHTML 点击;

If WebBrowserEx1.Document.All.Item(k).OuterHtml = "<input type="submit" value="Devam Et" onclick="return validatee();" style="background:#F79F81;font-weight:bold">" Then
     WebBrowserEx1.Document.All.Item(k).InvokeMember("click")
     Exit For
End If

但到目前为止,我无法成功。因为,我认为,这个控件的格式与后面的代码不同。我之前在某些按钮上成功了(通过更改格式、更改类型、样式等的顺序)

应该有一些更好的方法可以在不使用 .outerHTML 的情况下做到这一点。

4

1 回答 1

0

You could iterate through the forms, at least that's better than iterating through all the elements on the page. The example below is from http://msdn.microsoft.com/en-us/library/system.windows.forms.htmldocument.forms.aspx#Y106

For Each FormElem As HtmlElement In WebBrowser1.Document.Forms
    FormElem.InvokeMember("reset")
Next 
于 2012-09-13T12:17:06.870 回答