tags:

views:

253

answers:

3

hi,

I'm creating an automated tests that should navigate back a few steps. Is it possible to do so in Watir??

I'm navigating to a resultlist page and want to go back to the start of my test just by clicking back (windows browser). Thnx

A: 

This is how i tried to do it:

@site.ie.wait_until(1200) { |ie| ie.contains_text(/Sort after/) }
  2.times{@site.ie.back
}
Rida
The problem is solved.ie.back works can be used, i didn'r put the code in right place.
Rida
+1  A: 

If you have a Watir::IE object, then #back is a method that does what you are looking for:

http://wtr.rubyforge.org/rdoc/classes/Watir/IE.html#M000245

What error are you seeing?

mandersn
Yepp, this worked well for me, thnx m8
Rida
A: 

Example code that uses Watir's #back call (based on the standard Wikipedia example):

 require 'watir'
 test_site = 'http://www.google.com/'
 ie = Watir::IE.new
 ie.goto(test_site)
 ie.text_field(:name, "q").set("pickaxe")
 ie.button(:name, "btnG").click

 if ie.text.include?("Programming Ruby")  
   puts "Test Passed. Found the test string: 'Programming Ruby'."
 else
   puts "Test Failed! Could not find: 'Programming Ruby'." 
 end

 ie.back

 if ie.url == test_site
   puts "Test Passed. Returned to search page."
 else
   puts "Test Failed! URL is now #{ie.url}."
 end

 ie.close
mandersn