How to click a Link on a webpage using VBScript

99封情书 提交于 2021-02-04 14:18:47

问题


Actually i have to click on a link and as a result it will be give two menu list in that i need to select any of those

here is my VBScript for launching IE and navigate to required web adress

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

Can any any one help me out to click on that link and select any one of those menu source for the link

Actual source for the link :

<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>

Thanks in advance


回答1:


For this scenario you can use the method "getElementById". For example:

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

So your code will look something like:

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

There are also other methods you can use to access and click elements on a page, I refer to the following for a list:

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



来源:https://stackoverflow.com/questions/18593499/how-to-click-a-link-on-a-webpage-using-vbscript

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!