Quantcast
Channel: Windows PowerShell forum
Viewing all articles
Browse latest Browse all 21975

IE Automation - cannot access frameset

$
0
0

Hi all

I'm piecing together some IE automation tools using powershell to bulk process some jobs on one of our intranet sites.

I did some initial test runs in VBA and have now moved onto Powershell.  One of the pages I have to interact with contains a frameset - in the past when I've come up against this I've used the source document within a particular frame and not dealt with the frameset, however this particular page requires the frames to interact with each other.

In VB my working code to access the document within each frame was as follows:

Dim doc As Object
Set doc = ie.Document.frames("mainframe").Document

I've tried directly pulling this across to powershell as follows:

$doc = $ie.Document.frames('mainframe').Document

However it continually throws up the following error: Method invocation failed because [mshtml.HTMLDocumentClass] doesn't contain a method named 'frames'.

I've tried indexing the frames instead as follows:

$doc = $ie.Document.frames[0].Document

However this pulls back a similar error: Unable to index into an object of type mshtml.HTMLWindow2Class.

If I just look at the frames object itself I get the below output, which crucially contains a length of 4 - the exact number of frames I would expect.  This puzzles me as well, because presumably anything with a length should be indexable.  Can anyone shed any light as to why I can't access the frame?  What am I missing?  Thanks in advance.

length                          : 4
frames                          : mshtml.HTMLWindow2Class
defaultStatus                   : 
status                          : Applet JXFSApplet started
Image                           : 
location                        : System.__ComObject
history                         : System.__ComObject
opener                          : 
navigator                       : System.__ComObject
name                            : 
parent                          : mshtml.HTMLWindow2Class
self                            : mshtml.HTMLWindow2Class
top                             : mshtml.HTMLWindow2Class
window                          : mshtml.HTMLWindow2Class
onfocus                         : 
onblur                          : 
onload                          : 
onbeforeunload                  : 
onunload                        : 
onhelp                          : 
onerror                         : 
onresize                        : 
onscroll                        : 
document                        : mshtml.HTMLDocumentClass
event                           : 
_newEnum                        : 
screen                          : System.__ComObject
Option                          : 
closed                          : False
clientInformation               : System.__ComObject
offscreenBuffering              : auto
external                        : System.__ComObject
screenLeft                      : 479
screenTop                       : 207
onbeforeprint                   : 
onafterprint                    : 
clipboardData                   : System.__ComObject
frameElement                    : 
IHTMLWindow2_length             : 4
IHTMLWindow2_frames             : mshtml.FramesCollectionClass
IHTMLWindow2_defaultStatus      : 
IHTMLWindow2_status             : Applet JXFSApplet started
IHTMLWindow2_Image              : mshtml.HTMLImageElementFactoryClass
IHTMLWindow2_location           : System.__ComObject
IHTMLWindow2_history            : System.__ComObject
IHTMLWindow2_opener             : 
IHTMLWindow2_navigator          : System.__ComObject
IHTMLWindow2_name               : 
IHTMLWindow2_parent             : mshtml.HTMLWindow2Class
IHTMLWindow2_self               : mshtml.HTMLWindow2Class
IHTMLWindow2_top                : mshtml.HTMLWindow2Class
IHTMLWindow2_window             : mshtml.HTMLWindow2Class
IHTMLWindow2_onfocus            : 
IHTMLWindow2_onblur             : 
IHTMLWindow2_onload             : 
IHTMLWindow2_onbeforeunload     : 
IHTMLWindow2_onunload           : 
IHTMLWindow2_onhelp             : 
IHTMLWindow2_onerror            : 
IHTMLWindow2_onresize           : 
IHTMLWindow2_onscroll           : 
IHTMLWindow2_document           : mshtml.HTMLDocumentClass
IHTMLWindow2_event              : 
IHTMLWindow2__newEnum           : 
IHTMLWindow2_screen             : System.__ComObject
IHTMLWindow2_Option             : mshtml.HTMLOptionElementFactoryClass
IHTMLWindow2_closed             : False
IHTMLWindow2_clientInformation  : System.__ComObject
IHTMLWindow2_offscreenBuffering : auto
IHTMLWindow2_external           : System.__ComObject
IHTMLWindow3_screenLeft         : 479
IHTMLWindow3_screenTop          : 207
IHTMLWindow3_onbeforeprint      : 
IHTMLWindow3_onafterprint       : 
IHTMLWindow3_clipboardData      : System.__ComObject
IHTMLWindow4_frameElement       : 


Viewing all articles
Browse latest Browse all 21975

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>