如果我打开IE并转到我需要的页面
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(“input”)'
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 :(得分:0)
我明白了。 变 设置输入= frame.contentwindow.document.getElementsByTagName("输入") 至 设置输入= frame.contentDocument.getElementsByTagName("输入")