#608 win32com and PAMIE 3

closed-invalid
nobody
com (105)
5
2012-11-24
2012-08-29
Raveesh
No

I am trying to run the Simple Example to automate a google search on "Python"
http://mail.python.org/pipermail/python-announce-list/2009-March/007279.html

######################################################
from PAM30 import PAMIE

ie = PAMIE()
ie.navigate("google.com")
ie.setTextBox("q", "python")
ie.clickButton("Google Search")
ie.clickLink("Python Programming Language -- Official Website")

######################################################
I have the exact same setup as mentioned in the note by Rob Marchetti. Note:This version only only works with Python 3.0 on Windows and
requires Mark Hammond's pywin32 for Python3.0 - pywin32-213.win32-py3.0.exe

But i get the following error:
TypeError: getElementsByTagName() takes exactly 1 positional argument (2 given)

Details:
Traceback (most recent call last):
File "testPAM.py", line 10, in <module>
ie.setTextBox("q", "python")
File "C:\Users\raveesh\Dropbox\myCode\SSSB\PAM30.py", line 2093, in setTextBox
foundElement = self.getTextBox(name)
File "C:\Users\raveesh\Dropbox\myCode\SSSB\PAM30.py", line 1717, in getTextBox
foundElement = self.findElement("input", "id;name;value", name)
File "C:\Users\raveesh\Dropbox\myCode\SSSB\PAM30.py", line 445, in findElement
elements = self.getElementsList(tag)
File "C:\Users\raveesh\Dropbox\myCode\SSSB\PAM30.py", line 939, in getElementsList
elements = self._ie.Document.getElementsByTagName(tag)
TypeError: getElementsByTagName() takes exactly 1 positional argument (2 given)

Python on my machine: Python 3.0.1 (r301:69561, Feb 13 2009, 20:04:18) [MSC v.1500 32 bit (Intel)] on win32

The bug has also been reported on http://stackoverflow.com/questions/11580340/typeerror-with-pamie with no solution!

Discussion

  • Roger Upole
    Roger Upole
    2012-08-29

    • labels: 518543 --> com
    • status: open --> pending
     
  • Roger Upole
    Roger Upole
    2012-08-29

    The first thing to try is using a newer version of Python 3. There were enough problems with Python 3.0 that pywin32 is no longer released for it.

     
  • Raveesh
    Raveesh
    2012-08-30

    Hi, following you suggestion i upgraded to Python 3.x. Here is the exact version:
    Python 3.2.3 (default, Apr 11 2012, 07:15:24) [MSC v.1500 32 bit (Intel)] on win32
    And i have installed pywin32-217.win32-py3.2 from sourceforge

    I still get the same TypeError: getElementsByTagName() takes exactly 1 positional argument (2 given)

     
  • Raveesh
    Raveesh
    2012-08-30

    i am running this on a 64bit Win7, Intel machine, if that has anything to do with this.

     
  • This has nothing to do with Python 3 or PAM. I get the same error using this script (with Python 2.2, win32all build 210, as well as Python 2.5 and win32all build 217). It only happens with MSIE 9. Fun thing is that on a site like Baidu (commented line here), which uses compatibility mode IFAIK, it works. Tested on Win7 Ultimate 32 bits.

    import win32com.client
    import time

    ie = win32com.client.Dispatch('InternetExplorer.Application.1')
    try:
    ie.Visible = 1
    ie.Navigate("http://www.google.com")
    # ie.Navigate("http://www.baidu.com")

    while ie.Busy:
    time.sleep(1)

    print ie.Document.getElementsByTagName("a")
    finally:
    ie.Quit()

     
  • This is still "pending"... Should I open another bug report for my own situation ?

     
  • Mark Hammond
    Mark Hammond
    2012-09-16

    • status: pending --> open
     
  • Mark Hammond
    Mark Hammond
    2012-09-16

    I'll try and look into this soon.

     
  • Thanks.

     
  • Raveesh
    Raveesh
    2012-10-04

    As Jérome Laheurte (fraca7) mentioned this this appears to be an issue with Internet Explorer 9. I ran the same code on my Win Vista a week back and the code worked. I presume i still had IE 8 or earlier version on my machine. However, since the last Win update it appears IE 9 has been installed on my machine and this stops working again.

     
  • Raveesh
    Raveesh
    2012-10-04

    also PAM30.py is not compatible with Python 3 or higher versions. One will need to do some code modifications in PAM30.py like include new packages instead of the existing ones, and modify the print statements to the new print() function. But this is not as bad as the issues with IE 9. I will try to revert my IE to earlier versions.

     
  • Desmond Cox
    Desmond Cox
    2012-11-16

    I am seeing the same issue with my own custom IE automation script. Only started since "upgrade" to IE 9.

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

     
  • Mark Hammond
    Mark Hammond
    2012-11-24

    • status: open --> closed-invalid
     
  • Mark Hammond
    Mark Hammond
    2012-11-24

    I'm really not sure what pywin32 can do to work around this, given it is IE which has decided the signature of this function should change. I can only suggest PAMIE try and work around the problem by, eg, catching the exception and retrying with 2 args (or sniffing the IE version, etc)

     
  • The problem is, the recognized signature is empty (no argument except self). So no tag name to pass... But I concur that this is probably an IE bug, not a pywin32 one. A colleague of mine suggested that this may be related to the fact that IHTMLDocument8 inherits from IUnknown instead of IDispatch, but we don't know enough COM-fu to be sure.