Skip to content

Instantly share code, notes, and snippets.

@bootstraponline
bootstraponline / export.js
Created February 27, 2013 23:09
Export devices that pass 100% from AppThwack.
// device name : result
var pairs = $x('//*[@id="by_device"]/div/div/div');
for (var a = 0, len = pairs.length / 2; a < len; a+=2) {
if (all_passed(pairs[a+1])) {
console.log(device_name(pairs[a]));
}
}
// device name. pairs[0]
@bootstraponline
bootstraponline / appium_android.bash
Last active December 17, 2015 08:29
Start appium from source, open emulator, and cd into test folder.
# code goes in ~/.bash_profile
# tested on OS X
export APPIUM_HOME="$HOME/Desktop/appium"
export TEST_HOME="$HOME/path/to/tests"
export APPIUM_AVD="t18"
function three {
# does node exist?
[[ $(ps axo pid,command | grep "[0-9]\+ node" | wc -l) -gt 0 ]] && \
@bootstraponline
bootstraponline / fail.rb
Last active December 19, 2015 21:58
Parallel minitest
require 'rubygems'
$at_once = '3'
$total = 6
ENV['N'] = $at_once
require 'selenium-webdriver'
require 'minitest'
require 'minitest/hell'
@bootstraponline
bootstraponline / xml_to_txt.rb
Last active December 20, 2015 01:09
XML to txt
# gem install nokogiri escape_utils
text = ''
reader = Nokogiri::XML::Reader(File.open(file))
reader.each do |n|
text += ' ' + n.value + ' ' if n.value?
end
# double unescape
text = EscapeUtils.unescape_html text
text = EscapeUtils.unescape_html text
@bootstraponline
bootstraponline / js_vs_rb.md
Last active December 20, 2015 03:28
JavaScript vs Ruby

Ruby

scroll_to('views').click
scroll_to('tabs').click
scroll_to('content by id').click
s_text(0).selected?.must_equal false
s_text(1).selected?.must_equal true
@bootstraponline
bootstraponline / fail.rb
Last active December 20, 2015 14:39
Rewrite block source with instance eval
require 'rubygems'
require 'method_source'
ary = []
class Test
def self.run &block
define_method :run_method do
# https://www.ruby-forum.com/topic/4416134#1117671
eval %(ary << 1; puts 'complete'), block.binding
# Example of Ruby page object pattern
module App
module Splash
class << self
def login
'login'
end
end
end
@bootstraponline
bootstraponline / espresso_mvn_fail.md
Created October 23, 2013 15:06
Espresso package fail
	at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:130)
	... 20 more
Caused by: java.lang.NoClassDefFoundError: Lorg/sonatype/aether/RepositorySystem;
	at java.lang.Class.getDeclaredFields0(Native Method)
	at java.lang.Class.privateGetDeclaredFields(Class.java:2397)
	at java.lang.Class.getDeclaredFields(Class.java:1806)
	at com.google.inject.spi.InjectionPoint.getInjectionPoints(InjectionPoint.java:661)
	at com.google.inject.spi.InjectionPoint.forInstanceMethodsAndFields(InjectionPoint.java:366)
	at com.google.inject.internal.ConstructorBindingImpl.getInternalDependencies(ConstructorBindingImpl.java:165)
@bootstraponline
bootstraponline / taskport_osx10.9.xml
Last active December 28, 2015 15:29
system.privilege.taskport on OS X 10.9.
<!-- security authorizationdb read system.privilege.taskport > system.privilege.taskport.txt
DevToolsSecurity --enable
security authorizationdb write system.privilege.taskport is-developer
Fix developer popup.
Commands from: https://github.com/appium/appium/pull/1468
-->
<?xml version="1.0" encoding="UTF-8"?>
# Find open webviews on API 19 Android emulator.
def print_webviews
webviews = `adb shell cat /proc/net/unix`
webview_prefix = '@webview_devtools_remote_'
webviews = webviews.split("\r\n").reject { |l| ! l.include?(webview_prefix) }
# one pid may have many webviews
pids = webviews.map { |view| view.split(webview_prefix).last }.uniq