Skip to content

Instantly share code, notes, and snippets.

$ node .
info: Welcome to Appium v0.17.2 (REV f46a221b380630a1cbf6dbcb18511c3dc2d5e916)
info: Appium REST http interface listener started on 0.0.0.0:4723
   info  - socket.io started
info: Non-default server args: {"merciful":true}
debug: Appium request initiated at /wd/hub/session/9c4abc4d-917c-40be-8e44-36f45ae587ab
debug: Request received with params: {}
DELETE /wd/hub/session/9c4abc4d-917c-40be-8e44-36f45ae587ab 404 10ms - 53b
debug: Appium request initiated at /wd/hub/session
# 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
@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"?>
@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)
# Example of Ruby page object pattern
module App
module Splash
class << self
def login
'login'
end
end
end
@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
@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 / 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