|
Red Squirrel Reflections
Dave Hoover explores the psychology of software development
|
|
Thu, 13 Jul 2006If you haven't noticed, I'm a big fan of web testing tools like Selenium and Watir. As I prepared for my RailsConf talk (at RailsConf), surrounded by herds of Macs, I realized that Watir adoption in the Rails community was seriously not going to happen anytime soon without some cross-browser and cross-platform support. Without that support, I continue to recommend Selenium RC or Selenium on Rails to most Rails developers. And yet I still find myself infatuated with Watir's dead-simple setup (gem install watir and you're done) and intuitive API. So ... <deep-breath/> ... inspired by the Mac-centric tendencies of most of the Rails frontrunners, I have launched the SafariWatir project on RubyForge. There's not very much there yet. You can open and close Safari, fill out text fields, click buttons and links, ask whether the page contains text ... oh, and you can click alert boxes. I just discovered Apple's GUI Scripting integration with AppleScript, which makes it wonderfully easy to handle things that Windows makes incredibly difficult. (Apple provides GUI Scripting to facilitate universal access.) Watir (for IE) developers, you may want to look away, the following code could hurt... tell application "System Events" to tell process "Safari" tell window 1 if button named "OK" exists then click button named "OK" end if end tell end tellThat's all it takes to click an alert button in AppleScript. I wrap that in Ruby-goodness and stick it behind the Watir API, and man, I think this project is going to just about write itself. |