我正在开发一种在 Internet Explorer 中打开 Intranet 站点、输入数据并提交信息的自动化。
然而,该站点使用多个“iframe”和“框架”,即在顶级“iframe”下,将有另一个“iframe”,其中将有另一个“框架”,其中包含按钮和文本框。
Top level iframe
--control 1
--control 2
....
Second iframe
....
Third iframe
--control 1
--control 2
我能够访问顶级“iframe”下的控件,但是我的代码没有识别第二个“iframe”及其元素。
我怎样才能做到这一点?
下面是我的代码(frmMain 是顶级 iframe,modelframe1 和 modalframe2 是第二个和第三个)
Set doc = ie.Document
Set iframeDoc = doc.frames("frmMain").Document
Set objCollection = iframeDoc.getElementsByTagName("input")
objCount = 0
While objCount < objCollection.Length
Debug.Print objCollection(objCount).Name
If objCollection(objCount).Type = "submit" And objCollection(objCount).Name = "abc_name" Then
Set objElement = objCollection(objCount)
objElement.Click
End If
objCount = objCount + 1
Wend