簡體   English   中英

使用vbscript自動化IE - 無法單擊按鈕

[英]Automate IE with vbscript - Can not click the buttons

有人可以給我一個提示,如何點擊按鈕(addButton)? 嘗試類似的東西
IE.Document.All.Item(“addButton”)。點擊(和更多),但這不起作用。

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>

請參考以下主題中的答案:

如何使用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

抱歉,是我的錯。

IE.Document.All.Item(“addButton”)。點擊工作正常,但我在錯誤的框架中......

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

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM