Quantcast
Channel: Planet Plone - Where Developers And Integrators Write
Viewing all articles
Browse latest Browse all 3535

Youenn Boussard: Automate action with mechanize

$
0
0

Mechanize is a great tool for web ressources access . It simulate an web browser. This library is a base of zope.testbrowser so if you have zope.testbrowser you have mechanize.

A little exemple : login in a plone portal

## first log to portal

>>> br = mechanize.Browser()

>>> br.open(‘http://localhost:8080/plone/login_form’)
>>> br.forms()[0].find_control(‘__ac_name’) = ‘admin’
>>> br.forms()[0].find_control(‘__ac_password’) = ‘admin’
>>> br.open(br.forms()[0].click())
<response_seek_wrapper …
>>> ‘admin’ in br._response.read()
True

And you can as zope.testbrowser navigate by clicking link, submitting form … An useful tool for automate borring zmi action.

 



Viewing all articles
Browse latest Browse all 3535

Trending Articles