Created
June 17, 2015 21:26
-
-
Save lippytak/b53552fd6834ef74f086 to your computer and use it in GitHub Desktop.
MBCW driver example
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 'selenium-webdriver' | |
require 'pry' | |
class MbcwDriver | |
def initialize | |
@driver = Selenium::WebDriver.for :firefox | |
end | |
def create_application(params) | |
### Params | |
# county: full name of one of the 18 CalWIN counties | |
# ex: San Francisco | |
# first_name | |
# last_name | |
# phone_number | |
# ex: 5101112222 (needs to be formatted this way) | |
# email_address | |
### | |
d.navigate.to "https://www.mybenefitscalwin.org" | |
d.find_element(:link_text, "Apply for Benefits Or Continue Application").click | |
d.find_element(:link_text, "Get Started").click | |
d.find_element(:id, "without-user").click | |
click("Continue") | |
sleep 1 | |
d.find_element(:link_text, params[:county]).click | |
sleep 1 | |
d.find_element(:id, "noTAC").click | |
sleep 1 | |
click("Continue") | |
sleep 1 | |
click("Continue") | |
d.find_element(:id, "ContentPlaceHolderPageContent_IUnderstandCheckBox").click | |
click("Next") | |
d.find_element(:id, "ContentPlaceHolderPageContent_CertifUC_HasUnderstoodCertificationCheckBox_CB").click | |
click("Next") | |
d.find_element(:id, "FoodStamps").click | |
click("Next") | |
puts "Fill in the captcha, click Next, and then in terminal type 'exit'" | |
binding.pry | |
click("Next") | |
########################### | |
### People – Your Info ### | |
########################### | |
d.find_element(:id, "ContentPlaceHolderPageContent_AppInfo1UC_ApplicantFirstname_TB").send_keys(params[:first_name]) | |
d.find_element(:id, "ContentPlaceHolderPageContent_AppInfo1UC_ApplicantLastName_TB").send_keys(params[:last_name]) | |
# This always marks the client as NOT homeless — should check in on this | |
d.find_element(:id, "ContentPlaceHolderPageContent_AppInfo1UC_IsHomeless_YesNoRB_1").click | |
d.find_element(:id, "ContentPlaceHolderPageContent_AppInfo1UC_ContactTelephone_TB").send_keys(params[:phone_number]) | |
d.find_element(:id, "ContentPlaceHolderPageContent_AppInfo1UC_ApplicantEMail_TB").send_keys(params[:email_address]) | |
# If we have an email address, say we want info about application | |
# and info about case by email | |
if params[:email_address] && params[:email_address] != '' | |
d.find_element(:id, "ContentPlaceHolderPageContent_AppInfo1UC_GetAppInfoByEmail_YesNoRB_0").click | |
d.find_element(:id, "ContentPlaceHolderPageContent_AppInfo1UC_GetCaseInfoByEmail_YesNoRB_0").click | |
end | |
# Best way for the county to contact you (phone or email) - want to do? | |
# binding.pry | |
end | |
private | |
def click(name) | |
d.find_element(:link_text, name).click | |
end | |
def d | |
@driver | |
end | |
end | |
params = { county: 'San Francisco', first_name: 'Test', last_name: 'Test', phone_number: '3121112222', email_address: 'test@example.com' } | |
MbcwDriver.new.create_application(params) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment