Skip to content

Instantly share code, notes, and snippets.

@jamesu
Created April 26, 2012 19:46
Show Gist options
  • Save jamesu/2502485 to your computer and use it in GitHub Desktop.
Save jamesu/2502485 to your computer and use it in GitHub Desktop.
Amiando ticket script.rb
# Script to automate reserving tickets from amiando.
# Polls the site using chromedriver, automatically selecting 1 ticket
# and moving to the next step.
#
# Please use responsibly.
#
require 'rubygems'
require "selenium/webdriver"
# Configuration
$driver_url = "http://www.amiando.com/euruko2012.html"
$driver_ticket = /Individual/
$driver_delay = 4.0
$driver = Selenium::WebDriver.for :chrome
def check_page
$driver.get $driver_url
els = $driver.find_elements(:class => 'category')
els.each do |el|
if el.text.match($driver_ticket)
puts "EL ? #{el.text}"
select = el.find_element(:tag_name => 'select') rescue nil
if select
select.find_element(:xpath => '//option[@value=1]').click
$driver.find_element(:id => "wizardNextButton").click
`say "We're ready!!!'"`
exit
end
end
end
end
while 1
puts "Checking..."
check_page
sleep($driver_delay)
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment