Skip to content

Instantly share code, notes, and snippets.

View leviwilson's full-sized avatar

Levi Wilson leviwilson

  • Northwoods
  • Colorado, USA
View GitHub Profile
@leviwilson
leviwilson / example.feature
Created April 22, 2013 16:20
Example to illustrate that RubyMine does not display error information if it happens in a cucumber hook
Feature: Illustrating that RubyMine eats error output in hooks
Scenario: Some scenario that should fail
When I so something that will fail
Then this step will never execute
@leviwilson
leviwilson / submodule_problem
Created May 4, 2013 16:33
Submodule problem
lwilson@levis-macbook leviwilson $ cd gametel/
lwilson@levis-macbook gametel (master) $ git submodule update --init --recursive
Submodule 'webview_sample' (git@github.com:cheezy/Androidwebviewsampleapp.git) registered for path 'webview_sample'
Cloning into 'webview_sample'...
remote: Counting objects: 92, done.
remote: Compressing objects: 100% (57/57), done.
remote: Total 92 (delta 16), reused 90 (delta 14)
Receiving objects: 100% (92/92), 60.76 KiB, done.
Resolving deltas: 100% (16/16), done.
fatal: reference is not a tree: 2f1fa3c2748dde3e8aa8cb5f0d38bbb24932f55f
@leviwilson
leviwilson / action_bar_example.rb
Created May 13, 2013 02:04
An example of how to call down into Solo::clickOnActionBarItem(int) using Gametel.
class SomeScreen
include Gametel
def click_menu_item(which)
platform.chain_calls do |d|
# get the id of the menu item, store it in @@id@@
d.id_from_name which, :target => :Brazenhead, :variable => '@@id@@'
# give the @@id@@ back to Robotium to click on the menu option
d.click_on_action_bar_item '@@id@@', :target => :Robotium
end
class AddReserves
include Mohawk
select_list(:appointment_type, :id => 'whatever')
def any_checked?
appointment_type_options.any? &method(:checked?)
end
def checked?(which_type)
@leviwilson
leviwilson / multiple_page_navigation_example.rb
Last active December 17, 2015 20:49
Using gametel / mohawk within the same test suite
require 'page_navigation'
module Gametel
module Navigation
include PageNavigation
def on(cls, &block)
p "Gametel::PageNavigation - #{cls}"
end
end
end
@leviwilson
leviwilson / string.rb
Created May 29, 2013 17:05
String#to_american_date extension
require 'date'
class String
def to_american_date
Date.strptime(self, '%m/%d/%Y')
end
end
"06/05/2013".to_american_date #=> #<Date: 2013-06-05 ((2456449j,0s,0n),+0s,2299161j)>
@leviwilson
leviwilson / test.rb
Last active December 17, 2015 21:09 — forked from gjinfo737/test.rb
require 'gametel'
Gametel.apk_path = "../app/bin/CoPilot-debug.apk"
Gametel.start "_AppActivity"
@driver = Gametel.default_driver
@platform = @driver.platform
def tag_for(item, list, which_image=0)
@platform.get_view_by_index('android.widget.ListView', list) do |d|
@leviwilson
leviwilson / phone_gap_screen.rb
Created June 17, 2013 14:15
WebView proposed api
class PhoneGapScreen
include Gametel
webview(:id => 'webView1')
text_element(:username, :id => 'username-field')
text_element(:password, :class => 'password-class', :tagName => 'input')
button_element(:login, :value => 'Submit')
end
RSpec::Matchers.define :go_away do
match do |screen|
begin
RAutomation::WaitHelper.wait_until { !screen.present? }
rescue
raise "Expected #{screen.class} to go away but it is still present"
end
end
end
@leviwilson
leviwilson / README.md
Last active December 21, 2015 08:59
Issue loading GitHub Android's HomeActivity

Update

The brazenhead project had the android.support.v4.jar within its libs folder, even though it was not using it. This conflicted with the android.suppor.v4 that the app it was instrumenting was using. Removing this file fixed my issue.

Problem

The way brazenhead is able to instrument any apk for testing models this Robotium Wiki Page. Basically, you need these things to blackbox text any apk:

  • Test apk is signed with the same keystore as the apk you are testing
  • The targetPackage property is the same as the package of the apk that you are testing

That's pretty much it. Then, to launch any activity, you basically do what that article describes: