Skip to content

Instantly share code, notes, and snippets.

@leviwilson
Created August 31, 2012 16:37
Show Gist options
  • Save leviwilson/3555565 to your computer and use it in GitHub Desktop.
Save leviwilson/3555565 to your computer and use it in GitHub Desktop.
The gist of gametel driver

Command JSON Structure

  var singleCommand = {
    name:  "theMethodName",
    arguments:  ["array", 1, true, false, "of values to the method"],
    variable:  "@@variable_name_to_store_this_result@@", // (optional)
    target: "Robotium" // (optional) other option is LastResultOrRobotium (the default)
  };

Chaining method calls

The first method will be invoked upon Robotium. Every subsequent call will be invoked upon the last result.

Ruby Example

  http = Net::HTTP.new '127.0.0.1', 7777
  response = http.post '/', command({:name => 'getCurrentListViews'}, {:name => 'get', :arguments => [0]}, {:name => 'getChildCount' })
  count_of_listview_children = response.body

  def command(*commands)
    "commands=#{commands.to_json}"
  end

Java Equivalent

  private int getFirstListViewChildCount(final Solo solo) {
    final ListView listView = solo.getCurrentListViews().get(0);
    return listView.getChildCount();
  }

Capturing Results Into Variables

We can also capture results into variables, and pass them into other method calls.

Ruby Example

  http = Net::HTTP.new '127.0.0.1', 7777
  commands = [
    {:name => 'getText', :arguments => ['some text to find'], :variable => '@@the_view@@'},
    {:name => 'clickOnView', :arguments => ['@@the_view@@'], :target => 'Robotium'}
  ]
    
  response = http.post '/', command(*commands)

  def command(*commands)
    "commands=#{commands.to_json}"
  end

Java Equivalent

  private void clickOnText(final Solo solo, final String text) {
    final TextView foundText = solo.getText(text);
    solo.clickOnView(foundText);
  }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment