Skip to content

Instantly share code, notes, and snippets.

View alisterscott's full-sized avatar

Alister Scott alisterscott

View GitHub Profile
@alisterscott
alisterscott / wordpress-calypso-warn-on-publish.js
Last active April 12, 2016 15:58
A UserScript to prompt on publish for the WordPress.com Calypso client
// ==UserScript==
// @name WordPress Calypso Warn on Publish
// @version 0.1
// @description Warn on publish
// @author Alister Scott
// @match https://wpcalypso.wordpress.com/*
// @match http://calypso.localhost:3000/*
// @match https://wordpress.com/*
// @grant none
// ==/UserScript==
@alisterscott
alisterscott / quoth_example.rb
Created June 15, 2012 12:20
An example of using the quoth gem
require 'quoth'
puts Quoth.get
# If I have ventured wrongly, very well, life then helps me with its penalty.
# But if I haven't ventured at all, who helps me then? ~ Søren Kierkegaard
@alisterscott
alisterscott / uuid_example.rb
Created June 15, 2012 12:09
An example of how to use UUIDs in ruby
require 'securerandom'
puts SecureRandom.uuid
# ffe71bd2-2650-4135-b366-f8da08b4b708
@alisterscott
alisterscott / faker_example.rb
Created June 15, 2012 12:01
An example of the faker gem
require 'faker'
puts Faker::Name.name
# Nathanael Botsford
puts Faker::Company.name
# Labadie, Marvin and Kassulke
puts Faker::Company.catch_phrase
# Self-enabling bottom-line project
puts Faker::Company.bs
# grow B2C platforms
@alisterscott
alisterscott / watir-webdriver-downloads.rb
Created June 15, 2012 11:46
How to check for downloads to complete and get the file name
require 'watir-webdriver'
file_name = nil
download_directory = "#{Dir.pwd}/downloads"
download_directory.gsub!("/", "\\") if Selenium::WebDriver::Platform.windows?
downloads_before = Dir.entries download_directory
profile = Selenium::WebDriver::Firefox::Profile.new
profile['browser.download.folderList'] = 2 # custom location
profile['browser.download.dir'] = download_directory
@alisterscott
alisterscott / watir-webdriver_user_agent.rb
Created June 13, 2012 12:19
watir webdriver user agent example
require 'watir-webdriver'
require 'webdriver-user-agent'
driver = UserAgent.driver(:browser => :chrome, :agent => :iphone, :orientation => :landscape)
browser = Watir::Browser.new driver
browser.goto 'tiffany.com'
browser.url.should == 'http://m.tiffany.com/International.aspx'
@alisterscott
alisterscott / selenium_user_agent.rb
Created June 13, 2012 12:17
selenium webdriver user agent example
require 'selenium-webdriver'
require 'webdriver-user-agent'
driver = UserAgent.driver(:browser => :chrome, :agent => :iphone, :orientation => :landscape)
driver.get 'http://tiffany.com'
driver.current_url.should == 'http://m.tiffany.com/International.aspx'
@alisterscott
alisterscott / set_text_chrome_native.rb
Created June 6, 2012 11:04
Benchmarking the performance of a .set operation on a text field across browsers using watir-webdriver in ruby
require 'selenium-webdriver'
require 'watir-webdriver'
require 'bench'
d = Selenium::WebDriver.for :chrome, native_events: true
b = Watir::Browser.new d
b.goto 'bing.com'
benchmark 'set chrome native' do
b.text_field(name: 'q').set 'ghghghghghghghghghghghghghghghghghghghghghghghghghghghghghghghghghghghghghghghghghghghghghghghghghghghghghghghghghghghghghghghghghghghghghghghghghghghghghghghghghghghghghghghghghghghghghghghghghghghghghghghghghghghghghghghghghghghghghghghghghghghghghghghghghghghghghghghghghghghghghghghghghghghghghghghghghghghghghghghghghghghghghghghghghghghghghghghghghghghghghghghghghghghgh'
@alisterscott
alisterscott / block_suggestion.rb
Created May 31, 2012 23:41 — forked from natritmeyer/block_suggestion.rb
Page Object Management blog post material
visit LoginPage do |page|
page.login_with('foo', 'badpass')
page.text.should include "Login error"
page.text.should include "Secure your account"
end
@alisterscott
alisterscott / page_instance_variables.rb
Created May 30, 2012 04:58
Example of way to get rid of page instance variables from step defs
#https://github.com/natritmeyer/site_prism#epilogue
# was
@home = Home.new
@home.load
@home.search_field.set "Sausages"
@home.search_field.search_button.click
@results_page = SearchResults.new
@results_page.should have_search_result_items