VBA IE单击Javascript页面上的按钮



>我需要帮助来自动化网页。在登录页面上有登录按钮,但我没有找到如何单击它的方法。

网页代码

<INPUT onclick="return isFirstClick()" class=button type=submit value="Sign In">

使用下面不起作用

IE.document.getElementsByClassName("button")(0).Click

我也试图循环浏览元素,但没有运气。

谢谢。

您确定此按钮是网站上的第一个按钮吗?

您可以通过添加来检查它

Dim HTMLButtons As MSHTML.IHTMLElementCollection
Dim HTMLButton As MSHTML.IHTMLElement
Set HTMLButtons = HTMLDoc.getElementsByClassName("button")
debug.print HTMLButtons.length 'print how many buttons are in the html code
For Each HTMLButton In HTMLButtons
'printing some info about each button on the website
Debug.Print HTMLButton.className, HTMLButton.tagName, HTMLButton.ID, 
HTMLButton.innerText
Next HTMLButton

最新更新