def wait_until(timeout = $testwise_polling_timeout || 30, polling_interval = $testwise_polling_interval || 1, & block)
        end_time = ::Time.now + timeout

        until ::Time.now > end_time
          result = nil 
          begin 
            result = yield(self)
            return result if result	        
          rescue => e
          end
          sleep polling_interval
        end

        raise TimeoutError, "timed out after #{timeout} seconds"
      end
def wait_until(timeout = $testwise_polling_timeout || 30, polling_interval = $testwise_polling_interval || 1, & block)
        end_time = ::Time.now + timeout

        until ::Time.now > end_time
          result = nil 
          begin 
            result = yield(self)
            return result if result	        
          rescue => e
          end
          sleep polling_interval
        end

        raise TimeoutError, "timed out after #{timeout} seconds"
      end
= Convenient functions

 Execute the provided block until either (1) it returns true, or
 (2) the timeout (in seconds) has been reached. If the timeout is reached,
 a TimeOutException will be raised. The block will always
 execute at least once.

 This does not handle error, if the given block raise error, the statement finish with error
 Examples:
   wait_until {puts 'hello'}
   wait_until { div(:id, :receipt_date).exists? }