Why this simple scirpt fail(from tutorial)?

I have sth like this:

require ‘rubygems’
require ‘watir-webdriver’
@browser = Watir::Browser.new :firefox

def adopt_puppy_number(num)
@browser.button(:value => ‘View details’, :index => num - 1).click
@browser.button(:value => ‘Adopt Me!’).click
end

@browser.gotohttp://puppies.herokuapp.com
adopt_puppy_number 1
@browser.button(:value => ‘Adopt Another Puppy’).click
adopt_puppy_number 2

but I got :
/var/lib/gems/1.9.1/gems/watir-webdriver-0.9.1/lib/watir-webdriver/elements/element.rb:536:in
assert_element_found': unable to locate element, using {:value=>"View details", :index=>0, :tag_name=>"button"} (Watir::Exception::UnknownObjectException) from /var/lib/gems/1.9.1/gems/watir-webdriver-0.9.1/lib/watir-webdriver/elements/element.rb:508:inassert_exists’
from
/var/lib/gems/1.9.1/gems/watir-webdriver-0.9.1/lib/watir-webdriver/elements/element.rb:114:in
click' from /home/giz/Downloads/RubymineProjects/learn_watir/thirdscript_dry.rb:6:inadopt_puppy_number’
from
/home/giz/Downloads/RubymineProjects/learn_watir/thirdscript_dry.rb:11:in
<top (required)>' from -e:1:inload’
from -e:1:in `’

Why>
I searched sth like maye I shoud add some wait command bu WHERE exactly
and which one?
Thanks

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs