Skip to content

Instantly share code, notes, and snippets.

View tourdedave's full-sized avatar

Dave Piacente tourdedave

  • Applitools
  • Takoma Park, MD
View GitHub Profile
@tourdedave
tourdedave / XMLtoCSV.rb
Created October 30, 2012 00:56
XML to CSV for Less Accounting
require 'nokogiri'
require 'csv'
@xml = Nokogiri::XML(open("Old-Accounting-System.xml"))
@csv = CSV.open("output.csv", "w")
def populate(opts = Hash.new(0))
fields = []
payload = []
opts.each do |k,v|
@tourdedave
tourdedave / Check Please!
Last active December 12, 2015 01:48
Grab the contents of a page by url and css selector, strip out the html, and return just the copy. When run, it checks twice, storing a copy and latest_copy. This is then used to check and see if the site has changed, only notifying when it has.
#!/usr/bin/env ruby
require 'rest-client'
require 'nokogiri'
require 'sanitize'
class Checker
attr_accessor :url, :scope, :sleep_interval
attr_reader :page, :copy, :latest_copy
def initialize(url, scope, sleep_interval)
@tourdedave
tourdedave / gist:4757142
Created February 11, 2013 20:03
A quick and easy command-line progress bar
require 'ruby-progressbar'
progress_bar = ProgressBar.create(:total => @urls.count, :format => '%a |%b %i| %p%% Completed')
progress_bar.increment
@tourdedave
tourdedave / gist:5073541
Created March 2, 2013 22:23
Trying to call RSpec through code and load a custom formatter
require 'rspec'
require 'nyan_cat_formatter'
group = describe 2 do
it "should be two" do
2.should == 3 # failing test
end
it "should be two" do
2.should == 2
@tourdedave
tourdedave / reports.rb
Created March 28, 2013 13:22
A custom Cucumber Report Formatter to list all tags, how many of each there are, and sort them by that count.
module Report
class Tags
def initialize(step_mother, path_or_io, options)
@all_tags = []
end
def tag_name(tag_name)
@all_tags << tag_name
end
@tourdedave
tourdedave / nested_frames_example.rb
Created June 3, 2013 14:21
A Selenium WebDriver example of how to access elements within a nested frame.
require 'selenium-webdriver'
require 'rspec-expectations'
def setup
@driver = Selenium::WebDriver.for :firefox
end
def teardown
@driver.quit
end
3 processes for 26 beakers, ~ 8 beakers per process
Run options: include {:wip=>"true"}
Run options: include {:wip=>"true"}
Run options: include {:wip=>"true"}
Unable to download image!
[[ATTACHMENT|/Users/more/Dropbox/_dev/Arrgyle/Animoto/evidence/report_33451c6e722c4bedb9cb053ea5dd221b.log]]
[[ATTACHMENT|/Users/more/Dropbox/_dev/Arrgyle/Animoto/evidence/sauce_job_33451c6e722c4bedb9cb053ea5dd221b.log]]
F
# Elemental Selenium Tip 32 "XPath or CSS?"
# Directory Structure
# |-- config.rb
# |-- Rakefile
# `-- spec
# |-- id_and_class_spec.rb
# |-- spec_helper.rb
# `-- traversing_spec.rb
@tourdedave
tourdedave / chrome_32.log
Last active January 3, 2016 07:18
Selenium WebDriver performance benchmark comparing CSS and XPath on a Windows XP machine
user system total real
header_id_and_class using css 0.047000 0.109000 0.156000 ( 1.132802)
header_id_and_class using xpath 0.078000 0.141000 0.219000 ( 1.132802)
header_id_class_and_direct_desc using css 0.062000 0.078000 0.140000 ( 1.132802)
header_id_class_and_direct_desc using xpath 0.063000 0.031000 0.094000 ( 1.235784)
header_traversing using css 0.031000 0.172000 0.203000 ( 1.214156)
header_traversing using xpath 0.000000 0.140000 0.140000 ( 1.132800)
header_traversing_and_direct_desc using css 0.000000 0.125000 0.125000 ( 1.144128)
header_traversing_and_direct_desc using xpath 0.015000 0.079000 0.094000 ( 1.212096)
cell_id_and_class using css 0.016000 0.093000 0.109000 ( 1.121472)
div#sibling-1.1 + div#sibling-1.2 + div#sibling-1.3 > div#sibling-2.1 + div#sibling-2.2 + div#sibling-2.3 > div#sibling-3.1 + div#sibling-3.2 + div#sibling-3.3 > div#sibling-4.1 + div#sibling-4.2 + div#sibling-4.3 > div#sibling-5.1 + div#sibling-5.2 + div#sibling-5.3 > div#sibling-6.1 + div#sibling-6.2 + div#sibling-6.3 > div#sibling-7.1 + div#sibling-7.2 + div#sibling-7.3 > div#sibling-8.1 + div#sibling-8.2 + div#sibling-8.3 > div#sibling-9.1 + div#sibling-9.2 + div#sibling-9.3 > div#sibling-10.1 + div#sibling-10.2 + div#sibling-10.3 > div#sibling-11.1 + div#sibling-11.2 + div#sibling-11.3 > div#sibling-12.1 + div#sibling-12.2 + div#sibling-12.3 > div#sibling-13.1 + div#sibling-13.2 + div#sibling-13.3 > div#sibling-14.1 + div#sibling-14.2 + div#sibling-14.3 > div#sibling-15.1 + div#sibling-15.2 + div#sibling-15.3 > div#sibling-16.1 + div#sibling-16.2 + div#sibling-16.3 > div#sibling-17.1 + div#sibling-17.2 + div#sibling-17.3 > div#sibling-18.1 + div#sibling-18.2 + div#sibling-18.3 > div#sibling-19.1 + div#si