5 Replies - 3174 Views - Last Post: 06 May 2014 - 01:08 PM Rate Topic: -----

#1 hummhumm   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 4
  • Joined: 30-April 14

Mechanize - Button not in a form.

Posted 30 April 2014 - 03:07 PM

Hello all! I've been working with the python mechanize library recently and have run into a problem.
Is there a way to 'click' a button that isn't in a form field? It's just an element sitting out on its own. It would also be OK to call the playerStateAction() function, a javascript function they have made.

This is the html button:
<button onclick="playerStateAction('#reviewPlayer');"></button>


Is This A Good Question/Topic? 0
  • +

Replies To: Mechanize - Button not in a form.

#2 alexr1090   User is offline

  • D.I.C Head
  • member icon

Reputation: 44
  • View blog
  • Posts: 126
  • Joined: 08-May 11

Re: Mechanize - Button not in a form.

Posted 04 May 2014 - 06:26 AM

View Posthummhumm, on 30 April 2014 - 05:07 PM, said:

Hello all! I've been working with the python mechanize library recently and have run into a problem.
Is there a way to 'click' a button that isn't in a form field? It's just an element sitting out on its own. It would also be OK to call the playerStateAction() function, a javascript function they have made.

This is the html button:
<button onclick="playerStateAction('#reviewPlayer');"></button>

I did use mechanize a while back when I was trying to automate internet browser tasks and I believe I ran into your issue. I abandoned mechanize in favor ofspynner. I liked spynner but I ran into some sort of problem which I don't exactly remember and ended up going with selenium, which isn't bad. I haven't messed with either for about a year now but I'd try spynner because I remember that was simpler to me at least. Good luck!
Was This Post Helpful? 1
  • +
  • -

#3 hummhumm   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 4
  • Joined: 30-April 14

Re: Mechanize - Button not in a form.

Posted 05 May 2014 - 01:31 PM

Spynner seems pretty good. I can't seem to install it correctly. I got the zip/tarball(whatever it was) and extracted the contents. I went to the directory of the setup.py file and ran this:

setup.py install


A few seconds later, it completed. There wasn't an error.
Now i try to import spynner:

import spynner


and get this error:

Traceback (most recent call last):
  File "<pyshell#0>", line 1, in <module>
    import spynner
  File "C:\Python27\lib\site-packages\spynner-2.17.dev0-py2.7.egg\spynner\__init__.py", line 2, in <module>
    from browser import *
  File "C:\Python27\lib\site-packages\spynner-2.17.dev0-py2.7.egg\spynner\browser.py", line 36, in <module>
    import autopy
ImportError: No module named autopy


Was This Post Helpful? 0
  • +
  • -

#4 hummhumm   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 4
  • Joined: 30-April 14

Re: Mechanize - Button not in a form.

Posted 05 May 2014 - 01:45 PM

Alright, I've installed autopy and some other modules manually. Eveything seems to work now. :withstupid:
Was This Post Helpful? 0
  • +
  • -

#5 alexr1090   User is offline

  • D.I.C Head
  • member icon

Reputation: 44
  • View blog
  • Posts: 126
  • Joined: 08-May 11

Re: Mechanize - Button not in a form.

Posted 06 May 2014 - 12:47 AM

Cool, glad you got it working. If you're using Windows my good friend pointed out this site which gives you access to download executables. The executables will install the package. If you're on Linux there's easy_install and also another program which I can't seem to remember right now. Either one of these may or may not make installing extensions easier for you. Have a good one!
Was This Post Helpful? 1
  • +
  • -

#6 hummhumm   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 4
  • Joined: 30-April 14

Re: Mechanize - Button not in a form.

Posted 06 May 2014 - 01:08 PM

Thanks man! Really helpful site.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1