[Zope3-checkins] SVN: Zope3/branches/testbrowser-integration/src/zope/testbrowser/ add example (as test) of using zope.testbrowser to access a real site

Benji York benji at zope.com
Wed Sep 21 20:57:26 EDT 2005


Log message for revision 38559:
  add example (as test) of using zope.testbrowser to access a real site
  

Changed:
  U   Zope3/branches/testbrowser-integration/src/zope/testbrowser/ftests/testdoc.py
  A   Zope3/branches/testbrowser-integration/src/zope/testbrowser/over_the_wire.txt

-=-
Modified: Zope3/branches/testbrowser-integration/src/zope/testbrowser/ftests/testdoc.py
===================================================================
--- Zope3/branches/testbrowser-integration/src/zope/testbrowser/ftests/testdoc.py	2005-09-21 20:15:24 UTC (rev 38558)
+++ Zope3/branches/testbrowser-integration/src/zope/testbrowser/ftests/testdoc.py	2005-09-22 00:57:25 UTC (rev 38559)
@@ -23,7 +23,7 @@
 
 def test_suite():
     return FunctionalDocFileSuite(
-        '../README.txt',
+        '../README.txt', '../over_the_wire.txt',
         optionflags=doctest.NORMALIZE_WHITESPACE|doctest.ELLIPSIS)
 
 if __name__ == '__main__':

Added: Zope3/branches/testbrowser-integration/src/zope/testbrowser/over_the_wire.txt
===================================================================
--- Zope3/branches/testbrowser-integration/src/zope/testbrowser/over_the_wire.txt	2005-09-21 20:15:24 UTC (rev 38558)
+++ Zope3/branches/testbrowser-integration/src/zope/testbrowser/over_the_wire.txt	2005-09-22 00:57:25 UTC (rev 38559)
@@ -0,0 +1,34 @@
+=================================
+Using testbrowser On the Internet
+=================================
+
+The ``zope.testbrowser`` module exposes a ``Browser`` class that
+simulates a web browser similar to Mozilla Firefox or IE.
+
+    >>> from zope.testbrowser.browser import Browser
+    >>> browser = Browser()
+
+It can send arbitrary headers; this is helpful for setting the language value,
+so that your tests format values the way you expect in your tests, if you rely
+on zope.i18n locale-based formatting or a similar approach.
+
+    >>> browser.addHeader('Accept-Language', 'en-US')
+
+The browser can `open` web pages:
+
+    >>> browser.open('http://google.com')
+    >>> browser.url
+    'http://www.google.com/'
+
+We'll put some text in the query box...
+
+    >>> browser.getControl(name='q').value = 'zope.testbrowser'
+
+...and then click the search button.
+
+    >>> browser.getControl('Google Search').click()
+    Traceback (most recent call last):
+    ...
+    RobotExclusionError: HTTP Error 403: request disallowed by robots.txt
+
+Oops!  Google doesn't let robots use their search engine.  Oh well.


Property changes on: Zope3/branches/testbrowser-integration/src/zope/testbrowser/over_the_wire.txt
___________________________________________________________________
Name: svn:eol-style
   + native



More information about the Zope3-Checkins mailing list