Re: [Zope3-dev] XPATH in zope.testbrowser, assertions in zope.testrecorder
Benji York wrote: Martin Aspeli wrote: o In zope.testbrowser, [snip] having the ability to select nodes > by XPATH would be incredibly useful Yep, I and others have thought the same thing. I imagine an existing library would be available to make this reasonably easy to implement? With ElementTree going into Python 2.5, I suspect testbrowser will grow XPath support. ElementTree does not contain XPath support. It has an expression syntax in .find() that it claims is a (small) subset of XPath, but really it isn't quite. I believe there's also a partial XPath implementation for ElementTree somewhere though, though due to limitations of ElementTree (no parent references) a full XPath implementation is not currently possible. Still, ElementTree .find() path support would be useful. lxml of course offers both .find() and a full-fledged XPath implementation. :) Regards, Martijn ___ Zope3-dev mailing list Zope3-dev@zope.org Unsub: http://mail.zope.org/mailman/options/zope3-dev/archive%40mail-archive.com
Re: [Zope3-dev] XPATH in zope.testbrowser, assertions in zope.testrecorder
Stephan Richter wrote: 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. I like the general "feel" of it. -- Benji York Senior Software Engineer Zope Corporation ___ Zope3-dev mailing list Zope3-dev@zope.org Unsub: http://mail.zope.org/mailman/options/zope3-dev/archive%40mail-archive.com
Re: [Zope3-dev] XPATH in zope.testbrowser, assertions in zope.testrecorder
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: Well Done! by SchoolTool Manager on ... A job well done. Then I would like something like this to work: >>> print Analyzer(browser).getTextOnly('//[EMAIL PROTECTED]"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( ... '//[EMAIL PROTECTED]"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 ___ Zope3-dev mailing list Zope3-dev@zope.org Unsub: http://mail.zope.org/mailman/options/zope3-dev/archive%40mail-archive.com
Re: [Zope3-dev] XPATH in zope.testbrowser, assertions in zope.testrecorder
Stephan Richter wrote: Sorry, I did not parse (or better, my lexicon did not recognize the patterm ;-) the last part of the sentence. You answered the question anyway. :) I often like the XPATH selection, but the simplicity of the current control selectors is very nice too and I would not want to miss it. That's what I wanted to know. I would be happy to replace the regex support with XPATH though. Me too, especially since the regex support is not documented and as such may be retracted in the future. :) 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"? -- Benji York Senior Software Engineer Zope Corporation ___ Zope3-dev mailing list Zope3-dev@zope.org Unsub: http://mail.zope.org/mailman/options/zope3-dev/archive%40mail-archive.com
Re: [Zope3-dev] XPATH in zope.testbrowser, assertions in zope.testrecorder
On Saturday 24 June 2006 21:43, Benji York wrote: > Stephan Richter wrote: > > On Saturday 24 June 2006 19:49, Martin Aspeli wrote: > >> In this case, having the ability to select nodes by XPATH would be > >>incredibly useful > > > > Yes, I have done that in SchoolTool already. > > I'm curious if the other ways of selecting things were no longer > necessary, or if each still had a place. Sorry, I did not parse (or better, my lexicon did not recognize the patterm ;-) the last part of the sentence. I often like the XPATH selection, but the simplicity of the current control selectors is very nice too and I would not want to miss it. I would be happy to replace the regex support with XPATH though. 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. Regards, Stephan -- Stephan Richter CBU Physics & Chemistry (B.S.) / Tufts Physics (Ph.D. student) Web2k - Web Software Design, Development and Training ___ Zope3-dev mailing list Zope3-dev@zope.org Unsub: http://mail.zope.org/mailman/options/zope3-dev/archive%40mail-archive.com
Re: [Zope3-dev] XPATH in zope.testbrowser, assertions in zope.testrecorder
Stephan Richter wrote: On Saturday 24 June 2006 19:49, Martin Aspeli wrote: In this case, having the ability to select nodes by XPATH would be incredibly useful Yes, I have done that in SchoolTool already. I'm curious if the other ways of selecting things were no longer necessary, or if each still had a place. -- Benji York Senior Software Engineer Zope Corporation ___ Zope3-dev mailing list Zope3-dev@zope.org Unsub: http://mail.zope.org/mailman/options/zope3-dev/archive%40mail-archive.com
Re: [Zope3-dev] XPATH in zope.testbrowser, assertions in zope.testrecorder
On Saturday 24 June 2006 19:49, Martin Aspeli wrote: > In this case, having the ability to select nodes by XPATH would be > incredibly useful - both for getControl()/getLink(), and for doing > assertions (fail if/unless this node exists). I imagine an existing > library would be available to make this reasonably easy to implement? Yes, I have done that in SchoolTool already. It uses straight libxml2, so no fancy lxml or ElementTree, but it works well. We use it far too little. The code is here: http://source.schooltool.org/viewcvs/trunk/schooltool/src/schooltool/testing/analyze.py?rev=5667&view=auto And here it is used: http://source.schooltool.org/viewcvs/trunk/schooltool/src/schooltool/commendation/Viewing.txt?rev=6137&view=auto Regards, Stephan -- Stephan Richter CBU Physics & Chemistry (B.S.) / Tufts Physics (Ph.D. student) Web2k - Web Software Design, Development and Training ___ Zope3-dev mailing list Zope3-dev@zope.org Unsub: http://mail.zope.org/mailman/options/zope3-dev/archive%40mail-archive.com
Re: [Zope3-dev] XPATH in zope.testbrowser, assertions in zope.testrecorder
Martin Aspeli wrote: o In zope.testbrowser, [snip] having the ability to select nodes > by XPATH would be incredibly useful Yep, I and others have thought the same thing. I imagine an existing library would be available to make this reasonably easy to implement? With ElementTree going into Python 2.5, I suspect testbrowser will grow XPath support. o In zope.testrecorder, the ability to add comments that become DocTest comments is a stroke of genius. What I'd love to see, though, is the ability to add assertions for text. We've considered that too. Patches welcome. :) o Finally, zope.testrecorder always records full URLs, e.g. http://localhost:8080/test/foo. It would be nice if it could render those in the doctest at least with some variable substitution, e.g.: Good idea. The post-record screen (where you choose either Selenium or testbrowser output) would be a good place for that. You could choose any substitution you wanted for the host and port portion of the URIs, defaulting to whatever the actual value was. We would have to handle the case when more than one base was recorded during the session. -- Benji York Senior Software Engineer Zope Corporation ___ Zope3-dev mailing list Zope3-dev@zope.org Unsub: http://mail.zope.org/mailman/options/zope3-dev/archive%40mail-archive.com
[Zope3-dev] XPATH in zope.testbrowser, assertions in zope.testrecorder
Hi guys, I just started using zope.testbrowser and zope.testrecorder for doing integration tests. The case study is Ploneboard, the long-overdue message board for Plone, which has a workflow maze to compete with the best of them. Permissions control actions like reply, delete, edit and approve/moderate, which vary according to the different types of forum (e.g. moderated vs. non-moderated), and forms can get pretty complex. zope.testbrowser gives us a way to sanity-check all that - I love it :) There are three features I've found myself missing, though. o In zope.testbrowser, I sometimes need to be quite specific; for example, let's say I need to test that user A can see an 'edit' button on his own post, but not on the post by user B, both of which appear on the same page. In this case, having the ability to select nodes by XPATH would be incredibly useful - both for getControl()/getLink(), and for doing assertions (fail if/unless this node exists). I imagine an existing library would be available to make this reasonably easy to implement? o In zope.testrecorder, the ability to add comments that become DocTest comments is a stroke of genius. What I'd love to see, though, is the ability to add assertions for text. Basically, if I could mark some text in the browser and have that become a statement like >>> browser.contents '...some text in the browser...' ... then that would go a long way towards making the post-processing of the rendered DocTest a very minimal exercise. o Finally, zope.testrecorder always records full URLs, e.g. http://localhost:8080/test/foo. It would be nice if it could render those in the doctest at least with some variable substitution, e.g.: >>> baseUrl = 'http://localhost:8080/test' ... >>> browser.open('%s/foo' % baseUrl) That way, I could make sure that in integration tests, the baseUrl was always valid and consistent without needing to do a lot of search-and-replace. Cheers, Martin ___ Zope3-dev mailing list Zope3-dev@zope.org Unsub: http://mail.zope.org/mailman/options/zope3-dev/archive%40mail-archive.com