Skip to content

Instantly share code, notes, and snippets.

@jkaihsu
Last active December 21, 2015 05:39
Show Gist options
  • Save jkaihsu/6258528 to your computer and use it in GitHub Desktop.
Save jkaihsu/6258528 to your computer and use it in GitHub Desktop.
Automate Adding People to the Guestlist

Install Gem

$ gem install watir-webdriver

Download Zipfile

https://code.google.com/p/chromedriver/downloads/list

  • For Macs download chromedriver_mac32_2.2.zip

Move ChromeDriver to /usr/local/bin

$ sudo mv ~/Downloads/chromedriver /usr/local/bin/

Run

$ ruby guest_list.rb

We can make this file beautiful and searchable if this error is corrected: No commas found in this CSV file in line 0.
first_name;last_name;email;guests;gender
jkai;hsu
rita;jindawong
fred;tandem
daniella;kaufman
sam;samskies
annie;zhou
jon;oei
christine;hsu
michael;hom
garrett;spitzer
karen;liu
melvin;yuen
gloria;zhu
johnny;guo
jenny;chin
larry;yau
stephen;nguyen
janet;tsai
molly;zee
adam;sartell
jenny;lum
oren;shiran
ambert;ho
brian;nguyen
matthew;hague
amy;chan
karl;hu
james;moony
kris;hines
sai-kit;chan
teri;yu
kevin;ko
jessica;liu
vivian;cheng
tracy;chow
celia;wong
evan;kuo
alice;lee
lisa;tran
myron;lee
peter;wong
rachel;zuzu
rohan;jain
kelly;miyashiro
brendan;hong
nam;hoang
matthew;liu
jay;lim
steve;cho
jessica;fu
chrystle;cu
catherine;cu
annie;phan
david;nguyen
diana;weng
joesph;anderson
diana;park
caitlin;harrington
joesph;silvashy
maya;swanson
karen;tran
jammie;presto
emily;basileo
kira;tsogoo
mia;chinbolor
annika;kapur
jesse;molina
feina;zheng
jasmine;chen
leyen;chang
hugh;chow
require 'watir-webdriver'
@browser = Watir::Browser.new :chrome
@url = 'http://venuedriver.com/audiosfd/apps/web/guestlist'
@file = 'guest_list.csv'
@guests = []
@email_type = [ '@gmail.com', '@yahoo.com', '@outlook.com']
@guest_count = ['+1','+2','+3','+4','+5']
@sex = ['male', 'female']
@char = ['','.','_']
CSV.foreach(@file, :headers => true, :col_sep => ?;) { |csv_obj| @guests << csv_obj.to_hash }
@guests.each do |guest|
guest['email'] = guest['first_name'] + @char.sample + guest['last_name'] + @email_type.sample
guest['guests'] = @guest_count.sample
guest['gender'] = @sex.sample
end
@browser.goto(@url)
@guests.each do |guest|
@browser.goto(@url)
@browser.select_list(:id, 'event').select('PIERCE FULTON Aug 17')
@browser.text_field(:name => 'first').set(guest['first_name'])
@browser.text_field(:name => 'last').set(guest['last_name'])
@browser.text_field(:name => 'email').set(guest['email'])
@browser.select_list(:name, 'extra_count').select(guest['guests'])
@browser.radio(:id, guest['gender']).set()
@browser.button(:id, 'submitButton').click
end
@Naomibabbe
Copy link

Hi

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment