VBA:如何在HREF和CLASS HTML标签的帮助下点击网页中的下拉菜单 [英] VBA: How to click a drop down in a web page with the help of HREF and CLASS HTML tag avilable
问题描述
我试图自动化一个我的网站在安全的服务器上工作,这些代码可以帮助我登录到网页,但之后我必须点击菜单栏中的下拉菜单,其中可用的HTML标签是CLASS,仅限HREF。
HTML
< li> ;
< a Class =childmenuhref =./ 1713363899 / ViewLogsPage>
< span>日志< / span>
< / a>
< / li>
我的VBA代码的一部分是
Dim MyHTML_Element as IHTMLElement
Set HTMLDoc = MyBrowser.document
对于HTMLDoc.getElementsByClassName中的每个MyHTML_Element (childmenu)
如果MyHTML_Element.href =./1713363899/ViewLogsPageThen MyHTML_Element.Click:
Exit
Next
但是这段代码不工作,并且在执行这行后跳过..... ClassName(childmenu)并跳转到END子节点,当我运行我的代码在调试模式。
如果Instr(MyHTML_Element.href,1713363899 / ViewLogsPage)然后MyHTML_Element.Click
如果不行,请先添加debug.print MyHTML_Element.href与If一致。正在下载页面时可能会生成链接。
I am trying to automate one of my website working on a secured server, the code which help me to log into the web page but after that I have to click a dropdown from a menu bar where the HTML tag available is CLASS and HREF only.
HTML
<li>
<a Class = "childmenu" href="./1713363899/ViewLogsPage">
<span>Logs</Span>
</a>
</li>
A part of my VBA code is
Dim MyHTML_Element as IHTMLElement
Set HTMLDoc = MyBrowser.document
For Each MyHTML_Element In HTMLDoc.getElementsByClassName ("childmenu")
If MyHTML_Element.href = "./1713363899/ViewLogsPage" Then MyHTML_Element.Click:
Exit For
Next
but this code not working and Skip after executing this line ".....ClassName ("childmenu")" and jump to END sub, when i run my code in Debug mode.
Try
If Instr(MyHTML_Element.href, "1713363899/ViewLogsPage") Then MyHTML_Element.Click
If not works, add debug.print MyHTML_Element.href before line with If. It is possible that link is generated while page is being download.
这篇关于VBA:如何在HREF和CLASS HTML标签的帮助下点击网页中的下拉菜单的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!