Skip to content

Instantly share code, notes, and snippets.

View ckenst's full-sized avatar

Chris Kenst ckenst

View GitHub Profile
@ckenst
ckenst / cypressLogin.js
Created October 30, 2020 02:53
Login Examples
describe('My Login application', () => {
it('Should login with valid credentials', () =>{
cy.visit(`https://the-internet.herokuapp.com/login`);
cy.get('#username')
.type('tomsmith')
cy.get('#password')
.type('SuperSecretPassword!')
@ckenst
ckenst / docker_selenium.rb
Created September 4, 2018 22:42
Selenium Test written in Ruby using the Chrome Docker Container
require 'selenium-webdriver'
require 'rspec/expectations'
include RSpec::Matchers
def setup
caps = Selenium::WebDriver::Remote::Capabilities.send("chrome")
# This url is the local access url of the docker container
@driver = Selenium::WebDriver.for(:remote, url: "http://0.0.0.0:4444/wd/hub", desired_capabilities: caps)
end
@ckenst
ckenst / print_browser_console.rb
Created November 29, 2017 22:20
Print browser console inlcuding JavaScript errors
def run
setup
yield
teardown
end
run do
@driver.get 'http://www.kenst.com/about'
expect(@driver.title).to eql "About – Chris Kenst's Blog"
@ckenst
ckenst / debug_binding_pry.rb
Last active November 29, 2017 22:18
Debugging a Selenium Test using binding.pry
require 'pry' # Add to gemfile if not already there
# Not a functioning test
# Also not the greatest example
def run
setup
yield
teardown
end
@ckenst
ckenst / Headless_Chrome_Example.rb
Last active August 28, 2017 02:50
A simple selenium script using chrome headless
require 'selenium-webdriver'
require 'rspec/expectations'
include RSpec::Matchers
def setup
options = Selenium::WebDriver::Chrome::Options.new
options.add_argument('--headless')
options.add_argument('--disable-gpu')
options.add_argument('--remote-debugging-port=9222')
@driver = Selenium::WebDriver.for :chrome, options: options
@ckenst
ckenst / Headless_Chrome_Example_pry.rb
Last active November 29, 2017 22:16
A previous example of headless chrome in Ruby using Selenium
# Using pry as our REPL of choice. Could also use irb
pry
require 'selenium-webdriver'
#set our driver to use chrome and pass in switches.
driver = Selenium::WebDriver.for :chrome, switches: %w[--headless --no-sandbox --disable-gpu --remote-debugin-port=9222]
#let's go to kenst.com & make sure we are on the page
driver.get 'http://www.kenst.com'
@ckenst
ckenst / stripe_modal.rb
Last active April 23, 2018 17:56
Selenium script for filling out stripe's checkout popup modal
# This selenium script will automatically fill out stripe's checkout popup modal
# from the example modal within Stripe's documentation
require 'selenium-webdriver'
require 'rspec/expectations'
def setup
@driver = Selenium::WebDriver.for :chrome
end
@ckenst
ckenst / UpdateCerts
Last active November 26, 2016 15:05
Update SSL certs RVM
$ rvm osx-ssl-certs status all
# Certificates for...
$ rvm osx-ssl-certs update all
# Updating certificates...
@ckenst
ckenst / selenium_irb.rb
Last active August 15, 2017 22:46
IRB Selenium example
#our REPL of choice is irb, could also use pry
irb
#require the selenium webdriver library
require 'selenium-webdriver'
#launch chrome as our driver
driver = Selenium::WebDriver.for :chrome
#navigate to google
@ckenst
ckenst / spec_helper.rb
Last active August 29, 2015 14:25
An example spec helper
require 'selenium-webdriver'
RSpec.configure do |config|
config.before(:each) do
case ENV['host']
when 'saucelabs'
caps = Selenium::WebDriver::Remote::Capabilities.send(ENV['browser'])
caps.version = ENV['browser_version']
caps.platform = ENV['operating_system']