Discussion:
[python-win32] Failure in calling ie.document.body.getElementsByTagName('div')
Johannes Frank
2015-03-08 03:46:57 UTC
Permalink
Hello Mark, hello everyone,

I just wanted to report that the following error occurs:

Traceback (most recent call last):
File
"C:\Python27\Lib\site-packages\pythonwin\pywin\framework\scriptutils.py",
line 326, in RunScript
exec codeObject in __main__.__dict__
File "C:\Users\jmfra_000\Documents\Python Scripts\IEControl.py", line 11,
in <module>
divs = ie.Document.body.GetElementsByTagName('div')
File "C:\Python27\lib\site-packages\win32com\client\dynamic.py", line
192, in __call__
return
self._get_good_object_(self._oleobj_.Invoke(*allArgs),self._olerepr_.defaultDispatchName,None)
com_error: (-2147352319, 'OLE error 0x80020101', None, None)

Here is my script:

import win32com.client

sh = win32com.client.Dispatch('Shell.Application')

windows = sh.Windows()

for window in windows:
if 'iexplore' in window.FullName.lower():
ie = window

divs = ie.Document.body.GetElementsByTagName('div')

There is no hurry to fix this (if at all) because it can be easily avoided
by calling:

divs = ie.Document.body.all.tags('div')

Calling the same in IronPython works both ways. I just thought you might be
interested.

Thank you for your attention

Cheers Johannes

Loading...