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 / memory_backed_disk.md
Created December 5, 2013 01:58
Create memory backed disk on OSX

Create a memory-backed disk in OSX. Useful for sending git filter-branch to it to speed things up.

# to mount
hdiutil attach -nomount ram://$(( 128 * 1024 * 2 )) # returns device with 128 MB (in 512k blocks)
diskutil erasevolume JHFS+ "tmp" /dev/disk1 # whatever the hdiutil command returns

# when done
diskutil unmount /dev/disk1
hdiutil detach /dev/disk1
@leviwilson
leviwilson / UIA.rb
Last active December 25, 2015 07:19
main_form = UIA.find_by_id('MainFormWindow')
main_form.children # => [...] array of 22 child elements
main_form.children.find {|e| e.name == 'DropDown List'}.children.map(&:name) # => ['Apple', 'Orange', 'Banana']
main_form.children.first.click
@leviwilson
leviwilson / multiple_screen_calls.rb
Created September 20, 2013 15:53
Calling same method for multiple screens
def show_deleted_for(cls)
on(cls).show_deleted = true
end
def hide_deleted_for(cls)
on(cls)show_deleted = false
end
[CaseActivityTab, MemberNotesTab].each do |cls|
show_deleted_for(cls)
@leviwilson
leviwilson / README.md
Last active December 22, 2015 22:39
Setting up Ruby / DevKit on Windows

Ruby on Windows Setup

Here are a few things you'll need to get ruby setup on your Windows machine.

Ruby Setup

Ruby 1.9.3 will work. Use the defaults, but choose to add all of the ruby executables to your path.

DevKit

DevKit is needed for ruby to be able to install native gems (compiled C++ code) to your system. Extract this into something like c:\DevKit and then run the following commands.

@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:

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 / 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
@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 / 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 / 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