Search the web
Sign In
New User? Sign Up
TestFirstUserInterfaces
? Already a member? Sign in to Yahoo!

Yahoo! Groups Tips

Did you know...
Message search is now enhanced, find messages faster. Take it for a spin.

Best of Y! Groups

   Check them out and nominate your group.
Having problems with message search? Fill out this form to ensure your group is one of the first to be migrated to the new message search system.

Messages

  Messages Help
Advanced
test-driven Ajax   Message List  
Reply | Forward Message #975 of 1052 |
Adam Sroka wrote:

> ...Given that most web apps
> today are highly dependent on the Ajax stack I would not trust these
> frameworks unless they have *greatly* improved since the last time I
> looked at them.

If I can avoid my usual plagues and disasters for just a couple more
weeks now, I will _finally_ be publishing a chapter of /TFUI/.
(Woo-hoo! and _incredibly_ sorry about the wait, everyone!)

The chapter shows how to use Rails and Ajax to write a test runner, in
the style of Watir or Selenium. It uses Ajax to edit and maintain test
cases in a web page, and tests target pages in an IFrame.

The chapter shows how to build the core of this tool from Rails, its
existing test rigs, and some new test rigs I assemble on the fly. It
invents:

assert_xpath
assert_js
assert_ajax

Anyone proficient with Rails can sample the test runner itself here:

http://phlip.svnrepository.com/svn/yar_wiki/README

It currently beats on a couple of my Rails projects. If you install it
but don't build a controller for it, you get assert_xpath and
assert_js. (Only the wiki can do assert_ajax!)

Here's an extreme example of assert_xpath:

assert_xml x.target!

assert_xpath '/ul/li/table/tr/td/strong[ . = "test_hammy_squirrel" ]' do
assert_xpath '../../../../ul/li/table/tr/td/strong[ . = "script" ]' do
assert_xpath '../../../../div[ . = "# something tests hammy squirrel" ]'
end
end

The first assertion takes a string, parses it as XML, and puts it into
a secret member variable called @xdoc. The assert_xpath requires a
valid path, so you can put lots of query details into the path. Then
assert_xpath upgrades @xdoc to point to the selected node, and it
calls a block. assert_xpath inside the block then works on the
selected node. In the above example (which could be more ...
exemplary), the nested assert_xpath calls respond by reaching back up
the tree of nodes, and finding distant cousins of the selected nodes.

assert_js lexes intermediate JavaScript source into XML, so
assert_xpath can then query out its important details:

assert_xpath '/form/textarea' do |textarea|
assert_js textarea.attributes['onkeydown'] do
assert_xpath 'Statement[1]' do
assert_xpath '//Identifier[ @name = "Callee" and . =
"editor_keydown" ]'
end
end
end

That might be better than "assert_match /onkeydown.*editor_keydown/,
my_javascript". The match could break when irrelevant details change.

assert_ajax works by registering a JavaScript callback to file when an
Ajax command finishes. You can populate the callback with assertions
to check that your Ajax updated your DOM correctly.

--
Phlip
http://c2.com/cgi/wiki?ZeekLand <-- NOT a blog!!



Thu Mar 8, 2007 5:46 pm

phlipcpp
Offline Offline
Send Email Send Email

Forward
Message #975 of 1052 |
Expand Messages Author Sort by Date

... If I can avoid my usual plagues and disasters for just a couple more weeks now, I will _finally_ be publishing a chapter of /TFUI/. (Woo-hoo! and...
Phlip
phlipcpp
Offline Send Email
Mar 8, 2007
5:46 pm
Advanced

Copyright © 2009 Yahoo! Inc. All rights reserved.
Privacy Policy - Terms of Service - Guidelines - Help