Skip to content

Instantly share code, notes, and snippets.

@tylerhunt
Created January 27, 2014 17:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tylerhunt/8653071 to your computer and use it in GitHub Desktop.
Save tylerhunt/8653071 to your computer and use it in GitHub Desktop.
Fetch the most recent power meter reading from EPB.
require 'io/console'
require 'capybara/dsl'
require 'capybara-webkit'
URL = 'https://webconnect.epb.net/iwr/consumption/customer-energyOnDemand.seam'
print 'Username: '
username = gets.chomp
print 'Password: '
password = STDIN.noecho(&:gets).chomp
puts
Capybara.javascript_driver = :webkit
session = Capybara::Session.new(:webkit).tap do |session|
session.visit URL
end
session.fill_in 'username', with: username
session.fill_in 'password', with: password
session.click_button 'Login'
reading = session.find('[id="energyOnDemand:j_id160"]').text
puts "Last Reading: #{reading}"
source 'https://rubygems.org/'
gem 'capybara'
gem 'capybara-webkit'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment