[Seaside] SmallHttpUnitTest

Roger Whitney whitney at cs.sdsu.edu
Tue Oct 19 18:45:45 CEST 2004


A while back there was some discussion about a building a Smalltalk 
framework for testing web pages. At least for VW users one now exists: 
SmallHttpUnitTest. It is available at the Cincom Public Repository. You 
can read more about it at:

	http://www.blainebuxton.com/projects/smallhttpunittest.htm

SmallHttpUnitTest was developed at Camp Smalltalk in Portland this 
summer by Blaine Buxton & myself. The goal was to produce a compact 
language to access and test web pages. It has been used both to test 
web pages and to extract date from web pages.

Below is an example SUnit test, which tests Seaside's Counter. To 
access a page one opens an HttpBrowser on a url. To access elements of 
the page one can send  the tag name as a message to the browser object, 
so browser h1 below returns all the h1 elements of the page. One can 
also access page elements via tag attributes. So browser foo: 'bar' 
will return all tags with attribute foo with value bar. One can nest 
messages so  "(browser p foo: 'bar') a" will return all anchor tags in 
side paragraphs that have an attibute foo with value 'bar'. See the 
above URL and the tests that come with SmallHttpUnitTest for more 
examples of usage.

testNavigation
	| browser |
	browser := HttpBrowser on: 'http://localhost:8008/seaside/go/counter'.
	self assert: (browser h1 allSatisfy: [:each | each text = '0']).
	self assert: (browser a text includesAllOf: #('++' '--')).

	browser click: [:a | a text = '++'].
	self assert: (browser h1 text includesExactly: #('1')).

	browser click: '++'.
	self assert: (browser h1 text includesExactly: #('2')).

	browser click: '--'.
	self assert: (browser h1 text includesExactly: #('1')).


----
Roger Whitney              Department of Computer Science
whitney at cs.sdsu.edu        San Diego State University
http://www.eli.sdsu.edu/   San Diego, CA 92182-7720
(619) 583-1978
(619) 594-3535 (office)
(619) 594-6746 (fax)



More information about the Seaside mailing list