[Zope3-dev] XPATH in zope.testbrowser, assertions in zope.testrecorder

Stephan Richter srichter at cosmos.phy.tufts.edu
Sat Jun 24 22:49:46 EDT 2006


On Saturday 24 June 2006 22:35, Benji York wrote:
> > I would also like to think much harder about a good set of HTML
> > analyzing tools; this function was supposed to be a start in the
> > right direction, but I never got around thinking harder about it.
>
> Which function is "this function"?

analyze.queryHTML() in the referenced SchoolTool code. I think some 
higher-level functions would be desirable, like: "Get text of the specified 
tag." or "Ensure that no links are broken." The latter is particularly useful 
when checking for security. But all of this should be an additional API on 
top of testbrowser of course. I think the following would be cool:

  >>> Analyzer(browser).checkForBrokenLinks()
  >>> Analyzer(browser).getText('//h1')
  'Title of Page'

Often I also have results of the sort:

  <div class="commendation">
    <h3>Well Done!</h3>
    <div style="font-size: 60%">
      by <span class="grantor">SchoolTool Manager</span>
      on <span class="date">...</span>
    </div>
    <div class="description">A job well done.</div>
  </div>

Then I would like something like this to work:

  >>> print Analyzer(browser).getTextOnly('//div[@class="commendation"]')
  Well Done!
  by SchoolTool Manager on ...
  A job well done.

All I want to ensure is that the right text is shown together. I do not care 
whether this commendation is the first, n-th or last commendation in the 
HTML.

In other scenarios I specifically want to test for order only:

  >>> Analyzer(browser).getTextInOrder(
   ... '//div[@class="commendation"]/h3')
  ['Good job!', 'Well Done', 'Fantastic'] 

As I said, I have not thought too hard about a specific API recommendation 
yet, but I believe I have enough experience now to think about it now.

Regards,
Stephan
-- 
Stephan Richter
CBU Physics & Chemistry (B.S.) / Tufts Physics (Ph.D. student)
Web2k - Web Software Design, Development and Training


More information about the Zope3-dev mailing list