Created
January 24, 2015 21:15
-
-
Save bowmande/b54cb1bfaf3b718ca4c8 to your computer and use it in GitHub Desktop.
Ruby Welbe Capybara script
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' | |
require 'pry' | |
class Welbe | |
include Capybara::DSL | |
def initialize | |
Capybara.default_driver = :selenium | |
end | |
def go! | |
visit "https://www.welbe.com" | |
# Login | |
find(".navbar-company").click_on "Login" | |
fill_in "Email", with: YOUR EMAIL | |
fill_in "Password", with: YOUR PASSWORD | |
click_on "Sign In" | |
find("a.close-button").click | |
log_activity | |
3.times { log_meal } | |
log_sleep | |
log_measure | |
log_savings | |
log_water | |
end | |
def log_activity | |
find("li.log-action.activity").click | |
fill_in "walking", with: 30 | |
click_on "Log Minutes" | |
end | |
def log_meal | |
find("li.log-action.meals").click | |
find(".logging-grid-row:nth-of-type(1) .logging-grid-item:nth-of-type(1) .icon-plus").click | |
click_on "Log Meal" | |
end | |
def log_sleep | |
find("li.log-action.sleep").click | |
find(".sleep-input .input-hours").set("7") | |
click_on "Log Sleep" | |
end | |
def log_measure | |
find("li.log-action.body_metrics").click | |
fill_in "pulse", with: 70 | |
click_on "Log Measurements" | |
end | |
def log_savings | |
find("li.log-action.savings").click | |
all(".savings-item").first.find(".icon-plus").click | |
click_on "Log Savings" | |
end | |
def log_water | |
find("li.log-action.water").click | |
find(".full").click | |
find(".logging-box .box-footer .btn").click | |
find("li.log-action.water").click | |
find(".logging-box .box-footer .btn").click | |
end | |
end | |
Welbe.new.go! |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment