2016-09-01 59 views
-2

如果我打開IE瀏覽器,並轉到我需要這個頁面直通輸入標籤循環工作錯誤使用VBScript

LocationURL = "https://secure4.billerweb.com/smg/BillerConsole/inetSrv?sessionHandle=oGWmOV1RQAkSijIxSWs8IjcShm7x4dZir/nuGysZmGsoWXrUY2w9NzE5MTMwNzAw&client=719130700&type=ApplicationMenu&action=Menu" 
Set ie = GetIEApp(LocationURL) 
Set aHTML = IE.document 
Set frames = aHTML.getElementsByTagName("frame") 
For Each frame In frames 
    Set inputs = frame.contentwindow.document.getElementsByTagName("input") 
    For Each obj In inputs 
     If obj.name = "serviceSelection.inputFieldList[0].accountNumber" Then 
      obj.value = "123" 
     End If 
     If obj.name = "serviceSelection.inputFieldList[0].reEnterAccountNumber" Then 
      obj.value = "123" 
     End If 
     If obj.value = "Continue" Then 
      obj.click 
     End If 
    Next 
Next 
Public Function GetIEApp(Location) 
    Dim objShell 
    Dim objWindows 
    Dim objWindow 
    Set objShell = CreateObject("Shell.Application") 
    Set objWindows = objShell.Windows 
    For Each objWindow In objWindows 
     If LCase(Left(objWindow.LocationURL,4)) = "http" Then 
      If LCase(Right(objWindow.FullName, 12)) = "iexplore.exe" Then 
       If InStr(objWindow.LocationURL,Location) Then 
        Set GetIEApp = objWindow 
       End If 
      End If 
     End If 
    Next 
    Set objWindow = Nothing 
    Set objWindows = Nothing 
    Set objShell = Nothing 
End Function 

如果我使用腳本打開IE瀏覽器,登錄然後轉到頁我得到一個錯誤

對象犯規支持此屬性或方法 'frame.contentwindow.document.getElementsByTagName( 「輸入」)'

Set IE = CreateObject("InternetExplorer.Application") 
Set WshShell = WScript.CreateObject("WScript.Shell") 
IE.Navigate "https://secure4.billerweb.com" 
IE.Visible = True 
While ie.Busy : WScript.Sleep 100 : Wend 
IE.Document.All.Item("loginid").Value = "myid" 
IE.Document.All.Item("password").Value = "mypass" 
IE.Document.getElementsByName("Login").Item(0).Click 
While ie.Busy : WScript.Sleep 100 : Wend 
WScript.Sleep 1000 
Call IE.document.parentWindow.execScript("top.header.selectGroup('1', 1)", "JavaScript") 
WScript.Sleep 500 
Call IE.document.parentWindow.execScript("top.header.preSubmit('inetSrv?type=WizardService&" & client & "&newBean=true')", "JavaScript") 
While ie.Busy : WScript.Sleep 100 : Wend 
WScript.Sleep 1000 
Set aHTML = IE.document 
Set iframes = aHTML.getElementsByTagName("frame") 
For Each frame In iframes 
    Set inputs = frame.contentwindow.document.getElementsByTagName("input") 
    For Each obj In inputs 
     If obj.name = "serviceSelection.inputFieldList[0].accountNumber" Then 
      obj.value = "123" 
     End If 
     If obj.name = "serviceSelection.inputFieldList[0].reEnterAccountNumber" Then 
      obj.value = "123" 
     End If 
     If obj.value = "Continue" Then 
      obj.click 
     End If 
    Next 
Next 

回答

0

我想通了。 更改 集輸入= frame.contentwindow.document.getElementsByTagName( 「輸入」) 到 集輸入= frame.contentDocument.getElementsByTagName( 「輸入」)