简体   繁体   中英

Automate IE with vbscript - Can not click the buttons

Can someone give me a hint, how to click the buttons (the addButton)? Tryed something like
IE.Document.All.Item("addButton").Click (and more) but that does not work.

HTML Code:

<form action="./snfDestServlet" method="post" id="destForm" enctype="multipart/form-data" accept-charset="UTF-8">
<div id="destBox" class="indented"><select id="destinations" size="6" name="dests">
<option value="scanToNet.factory.9">MDS</option>
<option value="scanToNet.factory.11">Host1-SMB</option>
<option value="scanToNet.factory.10">Host2-SMB</option>
</select>
</div>
<div id="destinationButtons">
<input type="submit" name="addButton" value="Hinzufügen..."></input>
<br></br>
<input type="submit" name="editButton" value="Bearbeiten..."></input>
<br></br>
<input type="submit" name="deleteButton" value="Löschen"></input>
</div>
<br class="clear"></br>

Please refer to my answer in the following thread:

How to click a Link on a webpage using VBScript

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

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

So your code will look something like:

Dim URL 
Dim IE 
Set IE = CreateObject("internetexplorer.application")
URL = "http://whateverURLyouWant.com" 
IE.Visible = True
IE.Navigate URL


 Do While IE.Busy
    WScript.Sleep 100
 Loop

IE.Document.getElementById("destinationButtons").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

Sorry my mistake.

IE.Document.All.Item("addButton").Click works fine, but i was in the wrong frame ...

Dim IE

Set IE = CreateObject("InternetExplorer.Application")

IE.Visible = 1 
IE.FullScreen = 0
IE.navigate "www.anything.com"

Do While (IE.Busy)
    WScript.Sleep (10)
Loop

IE.Document.getElementById("Button_ID").click

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM