TypeError with PAMIE

1.1k Views Asked by At

I am getting a TypeError with a very simple script on PAMIE, and I'm not sure what I can do. I had found an answer suggesting that the library, pywin32 might not have set a self argument for this particular method (getElementsByTagName) but I don't know for sure, as I don't know where to find the definition of it.

from  PAM30 import PAMIE

ie = PAMIE()
ie.navigate('google.com')
ie.getButtons()
ie.quit()
print 'done'

The error is:

Traceback (most recent call last):
  File "c:\pamie1.py", line 1, in <module>
    from  PAM30 import PAMIE
  File "C:\Python27\Lib\site-packages\PAM30.py", line 678, in getButtons
    return self.getElementsList("input", filter)
  File "C:\Python27\Lib\site-packages\PAM30.py", line 939, in getElementsList
    elements = self._ie.Document.getElementsByTagName(tag)
TypeError: getElementsByTagName() takes exactly 1 argument (2 given)

Here's the offending line in PAM30

elements = self._ie.Document.getElementsByTagName(tag)

where _ie_ is

self._ie = win32com.client.dynamic.Dispatch('InternetExplorer.Application')

I'm using Windows 7x64 with Python2.7 32bit

3

There are 3 best solutions below

0
likaiguo.happy On BEST ANSWER

sourceforge bug link

"Workaround" seems to be enable Compatibility View (Tools > Compatibility View settings > Display all websites in Compatibility View).

it is a bug of IE.

0
user2760386 On

Modify this line:

elements = self._ie.Document.getElementsByTagName(tag)

to

elements = self._ie.Document.Body.getElementsByTagName(tag)

0
Rob Marchetti On

Work around - Change in PAMIE30

elements = self._ie.Document.getElementsByTagName(tag)

to

elements = self._ie.Document.body.all.tags(tag)

This will work without the need to use Compatibility View!