lib/calabash-android/operations.rb in calabash-android-0.5.2 vs lib/calabash-android/operations.rb in calabash-android-0.5.3
- old
+ new
@@ -1145,9 +1145,21 @@
def record_end(file_name)
ni
end
+ def evaluate_javascript(query_string, javascript, opt={})
+ wait_for_elements_exist(query_string, {timeout: Calabash::Android::Defaults.query_timeout})
+ result = JSON.parse(http("/map", {query: query_string, operation: {method_name: 'execute-javascript'}, javascript: javascript}))
+
+ if result['outcome'] != 'SUCCESS' || result['results'].nil?
+ parsed_result = result['results'].map {|r| "\"#{r}\","}.join("\n")
+ raise "Could not evaluate javascript: \n#{parsed_result}"
+ end
+
+ result['results']
+ end
+
def backdoor(method_name, arguments = [], options={})
arguments = [arguments] unless arguments.is_a?(Array)
result = JSON.parse(http('/backdoor', {method_name: method_name, arguments: arguments}))
\ No newline at end of file