[Rspec-devel] Dead easy Watir AND Selenium
aslak hellesoy
aslak.hellesoy at gmail.com
Thu Sep 7 05:43:52 EDT 2006
Yesterday I added some Watir examples to RSpec's svn.
Today I added some Selenium (actually - Selenium Remote Control) examples.
It's dead easy to use both, and the Ruby code you end up writing is
actually quite similar. Here's a taste:
== Watir ==
require File.dirname(__FILE__) + '/rspec_watir'
context "Google's search page" do
setup do
@browser.goto('http://www.google.com')
end
specify "should find rspec's home page" do
@browser.text_field(:name, "q").set("rspec")
@browser.button(:name, "btnG").click
@browser.contains_text("rspec.rubyforge.org").should_be(true)
end
specify "should not find Ali G when I search for rspec" do
@browser.text_field(:name, "q").set("rspec")
@browser.button(:name, "btnG").click
@browser.contains_text("Ali G").should_be(false)
end
end
== Selenium ==
require File.dirname(__FILE__) + '/rspec_selenium'
context "Google's search page" do
setup do
@browser = Selenium::SeleneseInterpreter.new("localhost", 4444,
"*firefox", "http://www.google.no", 10000)
@browser.start
@browser.open('http://www.google.no')
end
specify "should find rspec's home page" do
@browser.type "name=q", "rspec"
@browser.click_and_wait "name=btnG"
@browser.is_text_present("rspec.rubyforge.org").should_be(true)
end
specify "should not find Ali G when I search for rspec" do
@browser.type "name=q", "rspec"
@browser.click_and_wait "name=btnG"
@browser.is_text_present("Ali G").should_be(false)
end
end
More information about the Rspec-devel
mailing list