Created
January 27, 2014 17:19
-
-
Save tylerhunt/8653071 to your computer and use it in GitHub Desktop.
Fetch the most recent power meter reading from EPB.
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 '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}" |
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
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