[Zope3-checkins] SVN: Zope3/trunk/src/zope/testbrowser/README.txt Add some docs for using underlying mechanize functionality to do introspection.

Jim Fulton jim at zope.com
Sun Nov 27 16:13:41 EST 2005


This test fails for me and for the buildbot machine:

   http://buildbot.zope.org:8002/Zope3%20trunk%202.4%20Linux%20zc-buildbot/builds/157/test_2/0

Did it pass fotr you?

I have backed it out.

Jim

Chris Withers wrote:
> Log message for revision 40363:
>   Add some docs for using underlying mechanize functionality to do introspection.
> 
> Changed:
>   U   Zope3/trunk/src/zope/testbrowser/README.txt
> 
> -=-
> Modified: Zope3/trunk/src/zope/testbrowser/README.txt
> ===================================================================
> --- Zope3/trunk/src/zope/testbrowser/README.txt	2005-11-24 16:16:33 UTC (rev 40362)
> +++ Zope3/trunk/src/zope/testbrowser/README.txt	2005-11-24 16:27:37 UTC (rev 40363)
> @@ -409,8 +409,31 @@
>      >>> browser.getControl('Tres')
>      <ItemControl name='single-select-value' type='select' optionValue='3'>
>  
> -Characteristics of controls and subcontrols are discussed below.
> +Characteristics of controls and subcontrols are discussed in the
> +'Control Objects' section below.
>  
> +Introspection to find controls returned by the server
> +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> +
> +testbrowser currently doesn't help much unless you already know the
> +controls you will be looking for, however, you can do some
> +introspection by utilizing the underlying mechanize functionality.
> +
> +For example, to find all checkboxes on a page:
> +
> +    >>> checkboxes = [c.name for c in
> +    ...               browser.getForm('controls').mech_form.controls 
> +    ...               if c.type=='checkbox']
> +    >>> len(checkboxes)
> +    3
> +    >>> checkboxes[0:2]
> +    ['single-unvalued-checkbox-value', 'single-valued-checkbox-value']
> +    
> +You can then get the actual control as follows:
> +
> +    >>> browser.getControl(name=checkboxes[2])
> +    <ListControl name='multi-checkbox-value' type='checkbox'>
> +
>  Control Objects
>  ~~~~~~~~~~~~~~~
>  
> 
> _______________________________________________
> Zope3-Checkins mailing list
> Zope3-Checkins at zope.org
> http://mail.zope.org/mailman/listinfo/zope3-checkins


-- 
Jim Fulton           mailto:jim at zope.com       Python Powered!
CTO                  (540) 361-1714            http://www.python.org
Zope Corporation     http://www.zope.com       http://www.zope.org


More information about the Zope3-Checkins mailing list