Skip to content

Instantly share code, notes, and snippets.

Avatar

Alister Scott alisterscott

View GitHub Profile
@alisterscott
alisterscott / wordpress-calypso-warn-on-publish.js
Last active Apr 12, 2016
A UserScript to prompt on publish for the WordPress.com Calypso client
View wordpress-calypso-warn-on-publish.js
// ==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 Jun 15, 2012
An example of using the quoth gem
View quoth_example.rb
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 Jun 15, 2012
An example of how to use UUIDs in ruby
View uuid_example.rb
require 'securerandom'
puts SecureRandom.uuid
# ffe71bd2-2650-4135-b366-f8da08b4b708
@alisterscott
alisterscott / faker_example.rb
Created Jun 15, 2012
An example of the faker gem
View faker_example.rb
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 Jun 15, 2012
How to check for downloads to complete and get the file name
View watir-webdriver-downloads.rb
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 Jun 13, 2012
watir webdriver user agent example
View watir-webdriver_user_agent.rb
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 Jun 13, 2012
selenium webdriver user agent example
View selenium_user_agent.rb
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 Jun 6, 2012
Benchmarking the performance of a .set operation on a text field across browsers using watir-webdriver in ruby
View set_text_chrome_native.rb
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 — forked from natritmeyer/block_suggestion.rb
Page Object Management blog post material
View block_suggestion.rb
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
Example of way to get rid of page instance variables from step defs
View page_instance_variables.rb
#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
You can’t perform that action at this time.