I was trying to automate rediff.com . I went from one page to other but when i came back i got staleException . I tried a lot but couldn't fix it. I am attaching the code snippet too. Any help would be appreciated.
@driver.get "http://shopping.rediff.com/?sc_cid=inhome_icon"
@driver.manage.window.maximize
wait = Selenium::WebDriver::Wait.new(:timeout => 10) # seconds
begin
element = wait.until { @driver.find_element(:xpath,".//*[@id='popular_cat']") }
ensure
box=@driver.find_element(:xpath,".//*[@id='popular_cat']")
end links=box.find_elements(:tag_name,"a")
puts "Total links are:#{links.size}"
links.each do |i|
puts "--------------------"
puts "Value of all links is:#{i.text}"
i.click
puts "Title of page is :#{@driver.title}"
@driver.get "http://shopping.rediff.com/?sc_cid=inhome_icon"
box=@driver.find_element(:xpath,".//*[@id='popular_cat']")
links=box.find_elements(:tag_name,"a")
end