我正在嘗試編寫腳本來驅動我的IExplorer。它可以正常工作,但是我需要在textarea
中輸入一個值,然後單擊一個按鈕,同時它們都沒有ID。我不知道如何使用VBScript在HTML DOM中移動,但建議某處以某種方式使用document.all
。我也在考慮使用JS腳本給它們ID,然後回去並使用document.getElementbyid
,但我不知道如何在VBScript中運行JS腳本,並考慮了初始化的文檔對象。我至今是:如何獲取VBScript中沒有ID的元素
Option Explicit
With CreateObject("InternetExplorer.Application")
.Visible = True
.Navigate "https://adwords.google.co.uk/um/Logout"
Do While .Busy
WScript.Sleep 100
Loop
.Document.getElementByID("Email").Value = "[email protected]"
.Document.getElementByID("Passwd").Value = "PWD"
'Note: You could just get the form and submit it, but
'you'll miss out on any special JavaScript associated
'with the Submit button.
.Document.getElementByID("signIn").Click
Do While .Busy
WScript.Sleep 100
Loop
.Navigate "https://adwords.google.co.uk/o/Targeting/Explorer?"
Do While .Busy
WScript.Sleep 100
Loop
'here begins the problem'
.Document.All.tags("sB5 sPEB").Value = "southpark"
'.Document.getElementsByTagName("sJ1").Click'
End With
而且,因爲我試圖填補該領域是
<textarea style="overflow-y: hidden; height: 36px;" class="sB5 sPEB"></textarea>
,它已沒有價值屬性是如何它的價值inputed?
您可能正在使用IE 8或以前的版本。 IE DOM不支持getElementsByClassName()。請檢查這個quirksmode.org/dom/w3c_core.html – Amol 2012-03-30 09:57:02