def try_for(timeout = $testwise_polling_timeout, polling_interval = $testwise_polling_interval || 1, &block)
      start_time = Time.now

      last_error = nil
      until (duration = Time.now - start_time) > timeout
        begin
          yield
          last_error = nil
					return true 
        rescue RWebSpec::Assertion => e1
          last_error = e1
        rescue ArgumentError => ae
          last_error = ae
        rescue RSpec::Expectations::ExpectationNotMetError => ree
          last_error = ree          
        rescue => e
          last_error = e
        end
        sleep polling_interval
      end

      raise "Timeout after #{duration.to_i} seconds with error: #{last_error}." if last_error
      raise "Timeout after #{duration.to_i} seconds."
    end
def try_for(timeout = $testwise_polling_timeout, polling_interval = $testwise_polling_interval || 1, &block)
      start_time = Time.now

      last_error = nil
      until (duration = Time.now - start_time) > timeout
        begin
          yield
          last_error = nil
					return true 
        rescue RWebSpec::Assertion => e1
          last_error = e1
        rescue ArgumentError => ae
          last_error = ae
        rescue RSpec::Expectations::ExpectationNotMetError => ree
          last_error = ree          
        rescue => e
          last_error = e
        end
        sleep polling_interval
      end

      raise "Timeout after #{duration.to_i} seconds with error: #{last_error}." if last_error
      raise "Timeout after #{duration.to_i} seconds."
    end
Try the operation up to specified timeout (in seconds), and sleep given interval (in seconds).
 Error will be ignored until timeout
 Example
    try_for { click_link('waiting')}
    try_for(10, 2) { click_button('Search' } # try to click the 'Search' button upto 10 seconds, try every 2 seconds
    try_for { click_button('Search' }