lib/cello/pageobjects/html_elements/element_helper.rb in cello-0.0.26 vs lib/cello/pageobjects/html_elements/element_helper.rb in cello-0.0.27

- old
+ new

@@ -56,9 +56,29 @@ #logger(name, __method__, type) { send(name).attribute_value(att) #} end + define_method "#{name}_wait_exists_for" do |timeout| + t = 0 + while send(name).exists? || t < timeout do + sleep 1 + t += 1 + end + true if t < timeout + false if t >= timeout + end + + define_method "#{name}_wait_visible_for" do |timeout| + t = 0 + while send(name).visible? || t < timeout do + sleep 1 + t += 1 + end + true if t < timeout + false if t >= timeout + end + method_name = "define_extras_for_#{type}" send(method_name, name) if respond_to? method_name end