有人可以给我一个提示,如何点击按钮(addButton)? 试过类似的东西 IE.Document.All.Item( “Add按钮”)。点击 (以及更多)但这不起作用。
HTML代码:
<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>
答案 0 :(得分:1)
请参阅以下主题中的答案:
How to click a Link on a webpage using VBScript
对于此方案,您可以使用方法“getElementById”。例如:
IE.Document.getElementById("destinationButtons").Click
所以你的代码看起来像是:
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
您还可以使用其他方法来访问和点击页面上的元素,我参考以下列表:
http://msdn.microsoft.com/en-us/library/ie/ms535862(v=vs.85).aspx
答案 1 :(得分:1)
抱歉我的错误。
IE.Document.All.Item(“addButton”)。点击工作正常,但我的框架错了......
答案 2 :(得分:0)
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