[Rspec-devel] Dead easy Watir AND Selenium

David Chelimsky dchelimsky at gmail.com
Thu Sep 7 09:02:47 EDT 2006


On 9/7/06, aslak hellesoy <aslak.hellesoy at gmail.com> wrote:
> Yesterday I added some Watir examples to RSpec's svn.

Have you tried this w/ firewatir?

> 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
> _______________________________________________
> Rspec-devel mailing list
> Rspec-devel at rubyforge.org
> http://rubyforge.org/mailman/listinfo/rspec-devel
>


More information about the Rspec-devel mailing list