From fe4e5354fc9dee569df5a9023b157ac37d2c89cb Mon Sep 17 00:00:00 2001 From: Martin Edenhofer Date: Tue, 18 Nov 2014 15:51:44 +0100 Subject: [PATCH] Improved "watch_for" with timeout option. --- test/browser_test_helper.rb | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/test/browser_test_helper.rb b/test/browser_test_helper.rb index 076d9ef1f..85239e7ad 100644 --- a/test/browser_test_helper.rb +++ b/test/browser_test_helper.rb @@ -250,12 +250,16 @@ class TestCase < Test::Unit::TestCase assert( false, "(#{test[:name]}) no login box found!" ) return elsif action[:execute] == 'watch_for' + timeout = 16 + if action[:timeout] + timeout = action[:timeout] + end + loops = timeout / 0.33 text = '' - (1..36).each { |loop| + (1..loops).each { |loop| element = instance.find_element( { :css => action[:area] } ) if element.displayed? text = element.text - puts "T: #{text}" if text =~ /#{action[:value]}/i assert( true, "(#{test[:name]}) '#{action[:value]}' found in '#{text}'" ) sleep 0.4