Created
October 14, 2012 01:56
-
-
Save oubiwann/3886983 to your computer and use it in GitHub Desktop.
zope.testbrowser: Automating the Web
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| >>> from zope.testbrowser.browser import Browser | |
| >>> b = Browser('http://google.com') | |
| >>> b.title | |
| 'Google' | |
| >>> b.getLink('About Google') | |
| <Link text='About Google' url='http://www.google.com/intl/en/about.html'> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| >>> b.getLink('About Google').click() | |
| >>> b.title | |
| 'About Google' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| >>> b.getLink('Investor Relations').click() | |
| >>> b.title | |
| 'Google Investor Relations' | |
| >>> b.getLink('Guidelines').click() | |
| >>> 'Corporate Governance' in b.contents | |
| True |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| >>> b = Browser('https://launchpad.net/+login') | |
| >>> b.title | |
| 'Log in or register with Launchpad' | |
| >>> b.getControl(name='loginpage_email', index=0).value = username | |
| >>> b.getControl(name='loginpage_password').value = passwd | |
| >>> b.getControl(name='loginpage_submit_login').click() | |
| >>> b.title | |
| 'Launchpad' | |
| >>> 'Logged in as' in b.contents | |
| True |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| >>> b.getLink('Duncan McGreggor').click() | |
| >>> b.title | |
| 'Duncan McGreggor in Launchpad' | |
| >>> b.getLink('http://www.advogato.org/person/oubiwann/') | |
| <Link text='http://www.advogato.org/person/oubiwann/' url='http://www.advogato.org/person/oubiwann/'> | |
| >>> b.getLink('Change details').click() | |
| >>> b.getControl(name='field.homepage_content').value = 'blog: http://oubiwann.blogspot.com' | |
| >>> b.getControl(name='field.actions.save').click() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| >>> b.getLink('http://www.advogato.org/person/oubiwann/') | |
| Traceback (most recent call last): | |
| [snip] | |
| mechanize._mechanize.LinkNotFoundError | |
| >>> b.getLink('http://oubiwann.blogspot.com') | |
| <Link text='http://oubiwann.blogspot.com' url='http://oubiwann.blogspot.com'> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment