lib/acouchi/solo.rb in acouchi-0.0.6 vs lib/acouchi/solo.rb in acouchi-0.0.7

- old
+ new

@@ -39,14 +39,28 @@ def has_button? text buttons.any? { |b| b["text"] == text } end + def text_views + call_method("getTextViews") + end + def content call_method("getCurrentContent") end + def all_content + all_content = [] + until scroll_up == false; end + begin + all_content << text_views.map {|t| t["text"]} + end while scroll_down + all_content << text_views.map {|t| t["text"]} + all_content.flatten.uniq + end + def click_text text, options={} options = { :match => 1, :auto_scroll => true }.merge(options) @@ -63,10 +77,14 @@ def click_view id call_method("clickOnViewById", [id]) end + def click_image index + call_method("clickOnImage", [index]) + end + def scroll_up call_method("scrollUp") end def scroll_down @@ -87,11 +105,16 @@ def scroll_to_right call_method("scrollToSide", [RIGHT]) end + def go_back + call_method("goBack") + end + private def call_method name, arguments = [] + arguments = arguments.map {|a| a.to_s} options = { :body => {:parameters => arguments.to_json} } response = HTTParty.post("http://127.0.0.1:7103/execute_method/#{name}", options) json = JSON.parse(response.body, :max_nesting => 100) if json.empty? nil