如何使用 VBScript 单击网页上的链接

2023-11-29

实际上我必须单击一个链接,结果它将给出两个菜单列表,我需要选择其中任何一个

这是我的 VBScript,用于启动 IE 并导航到所需的网址

Dim URL 
Dim IE 
Set IE = CreateObject("internetexplorer.application")
URL = "http://it-asg.uhc.com/sites/gcas/pcas/archive/PCR/IVM/modlist/Lists/ElementTracker/AllItems.aspx" 
IE.Visible = True
IE.Navigate URL

任何人都可以帮我点击该链接并选择其中任何一个菜单吗 链接的来源

链接的实际来源:

<a id="zz13_ListActionsMenu" accesskey="C" href="#" onclick="javascript:return false;" style="cursor ointer;white-space:nowrap;" onfocus="MMU_EcbLinkOnFocusBlur(byid('zz8_RptControls'), this, true);" onkeydown="MMU_EcbLinkOnKeyDown(byid('zz8_RptControls'), MMU_GetMenuFromClientId('zz13_ListActionsMenu'), event);" oncontextmenu="this.click(); return false;" menutokenvalues="MENUCLIENTID=zz13_ListActionsMenu,TEMPLATECLIENTID=zz8_RptControls" serverclientid="zz13_ListActionsMenu">Actions<img src="/_layouts/images/blank.gif" border="0" alt="Use SHIFT+ENTER to open the menu (new window)."></a>

提前致谢


对于这种情况,您可以使用方法“getElementById”。例如:

IE.Document.getElementById("zz13_ListActionsMenu").Click

所以你的代码看起来像这样:

Dim URL 
Dim IE 
Set IE = CreateObject("internetexplorer.application")
URL = "http://it-asg.uhc.com/sites/gcas/pcas/archive/PCR/IVM/modlist/Lists/ElementTracker/AllItems.aspx" 
IE.Visible = True
IE.Navigate URL


 Do While IE.Busy
    WScript.Sleep 100
 Loop

IE.Document.getElementById("zz13_ListActionsMenu").Click

您还可以使用其他方法来访问和单击页面上的元素,我参考以下列表:

http://msdn.microsoft.com/en-us/library/ie/ms535862(v=vs.85).aspx

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

如何使用 VBScript 单击网页上的链接 的相关文章

随机推荐