On Sunday 15 July 2007 10:44, Benji York wrote:
> > Right, z3c.etestbrowser does this already. I wish they would have done
> > this with a different object altogether, but they extended the
> > TestBrowser class. But then I do not have enough objectstion to write a
> > new package.
> Perhaps someone can explain the utility of z3c.etestbrowser.  As far as
> I can see, it just adds an "etree" attribute to browser instances.  That
> doesn't seem to have much advantage over just calling etree on
> browser.contents.

Right, right now it does not do much more. But I do not have to think about it 
and just use the attribute. I usually end up writing one more utility 
function that does an XPath expression selects the first result (which I am 
usually interested in) and prints that. I think this would make a great 
method on etestbrowser.

> I'm doing some work with doctest right now, and am considering how to
> make assertions about HTML/XML better.  The programmatic approach like
> above is one option.  Another would be to use a special checker that
> took into account HTML/XML structure.  For example, it could interpret
> ellipses differently such that
>      <foo ...>Text here</foo>
> would match
>      <foo a="b">Text here</foo>
> but not
>      <foo><bar/>Text here</foo>

I would not like that. I really, really like to use XPath to select an element 
in the HTML structure. The method above would still require me to write

  >>> print browser.contents
  <foo ...>Text here</foo>

So I really like this much better:

  >>> print browser.xpath1('//foo')
  <foo a="b">Text here</foo>

Of course, I really would prefer this:

  >>> print Introspector(browser).xpath1('//foo')
  <foo a="b">Text here</foo>

This is so that the browser features and content inspection are separated.

Stephan Richter
CBU Physics & Chemistry (B.S.) / Tufts Physics (Ph.D. student)
Web2k - Web Software Design, Development and Training
Zope3-dev mailing list
Unsub: http://mail.zope.org/mailman/options/zope3-dev/archive%40mail-archive.com

Reply via email to