-
-
Save joshuakemp1/c729523f8ad630d24d0c2bf9a541492a to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'capybara/poltergeist' | |
base_url = 'http://www.hyperiums.com/servlet/Login?login=&lang=0' | |
login_url = "#{base_url}servlet/Login?login=&lang=0" | |
hyperiums_username = 'YOUR USERNAME' # change these to yours | |
hyperiums_password = 'YOUR PASSWORD' # change these to yours | |
@cool_planet = 'http://hyp2.hyperiums.com/servlet/Planetfloats?tuto=build_factories&planetid=66225' | |
@cool_planet_id = '66225' | |
def log_into_hyperiums(username, password, login_url) | |
@session = Capybara::Session.new(:poltergeist) | |
@session.visit login_url | |
puts "On the: #{@session.current_url} page" | |
if @session.current_url == login_url | |
puts 'All shiny, captain!' | |
else | |
puts ':( On the wrong URL, exiting' | |
exit(-1) | |
end | |
@session.fill_in 'login', with: username | |
@session.fill_in 'pwd', with: password | |
@session.click_on 'Login' | |
puts 'about to sleep' | |
sleep 5 | |
puts 'done sleeping' | |
puts "#{@session.current_url}" | |
end | |
def build_factories | |
@session.click_on 'Go' | |
if @session.current_url == @cool_planet | |
puts 'Ready to start building factories!' | |
else | |
puts ':( Something went wrong, exiting' | |
exit(-1) | |
end | |
puts 'On the cool planet!' | |
end | |
# Run the script | |
log_into_hyperiums(hyperiums_username, hyperiums_password, login_url) # Headlessly logs into Hyperiums | |
build_factories |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment