lib/calabash-android/wait_helpers.rb in calabash-android-0.4.22.pre4 vs lib/calabash-android/wait_helpers.rb in calabash-android-0.5.0.pre1
- old
+ new
@@ -82,20 +82,31 @@
end
end
end
#options for wait_for apply
+ def wait_for_element_exists(uiquery, options={})
+ wait_for_elements_exist([uiquery], options)
+ end
+
+ #options for wait_for apply
def wait_for_elements_exist(elements_arr, options={})
if elements_arr.is_a?(String) || elements_arr.is_a?(Symbol)
elements_arr = [elements_arr.to_s]
end
options[:timeout_message] = options[:timeout_message] || "Timeout waiting for elements: #{elements_arr.join(",")}"
wait_for(options) do
elements_arr.all? { |q| element_exists(q) }
end
end
+
#options for wait_for apply
+ def wait_for_element_do_not_exist(uiquery, options={})
+ wait_for_elements_do_not_exist([uiquery], options)
+ end
+
+ #options for wait_for apply
def wait_for_elements_do_not_exist(elements_arr, options={})
if elements_arr.is_a?(String)
elements_arr = [elements_arr]
end
options[:timeout_message] = options[:timeout_message] || "Timeout waiting for no elements matching: #{elements_arr.join(",")}"
@@ -165,13 +176,30 @@
# Example usage: when_element_exists("Button", :timeout => 10)
def when_element_exists(uiquery, opts = {})
action = { :action => lambda { touch uiquery } }
opts = DEFAULT_OPTS.merge(action).merge(opts)
wait_for_elements_exist([uiquery], opts)
- opts[:action].call
+
+ if opts[:action].parameters.length == 0
+ opts[:action].call
+ else
+ opts[:action].call(uiquery)
+ end
end
+ def wait_for_text(text, options={})
+ wait_for_element_exists("* {text CONTAINS[c] '#{text}'}", options)
+ end
+ def wait_for_text_to_disappear(text, options={})
+ wait_for_element_do_not_exist("* {text CONTAINS[c] '#{text}'}", options)
+ end
+
+ def wait_for_activity(activity_name, options={})
+ wait_for(options) do
+ perform_action('get_activity_name')['message'] == activity_name
+ end
+ end
end
end
end