-
Notifications
You must be signed in to change notification settings - Fork 1
/
Payment_Request_Example.py
97 lines (82 loc) · 4.73 KB
/
Payment_Request_Example.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
import pandas as pd
import numpy as np
import time
import yaml
import datetime
from selenium import webdriver
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.support.ui import WebDriverWait as wait
from selenium.webdriver.support import expected_conditions as EC
#-----------------------------------------------------------------------------#
# LOGS YOU INTO TWC WEBSITE AND BEGINS THE PAYMENT REQUEST PROCESS
driver = webdriver.Firefox(executable_path=r'[path_to_geckodriver_executable]')
# Get your username and password from the YAML file.
conf = yaml.load(open(r'[path_to_your_credentials.yml]'))
my_username = conf['Unemployment']['username']
my_password = conf['Unemployment']['password']
def payment_request():
# CHECKS IF ITS TOO EARLY TO FILE. IF IT IS, THE SCRIPT STOPS.
driver.find_element_by_xpath('/html/body/div/div[3]/div[1]/div/ul[1]/li[4]/a').click()
if (driver.find_element_by_class_name('page-name').text) == 'Early Filing': driver.quit()
# IF IT ISN'T TOO EARLY TO FILE, THE PAYMENT REQUEST CONTINUES.
else:
# PULLS CLAIM WEEK DATES FROM THE TWC WEBPAGE
claim_week_pull = driver.find_element_by_class_name('page-header-row-value-1col').text[0:12]
claim_week_convert_to_str = claim_week_pull.replace(',','')
date_1 = datetime.datetime.strptime(claim_week_convert_to_str,r'%b %d %Y')
#---------------------------------------------------------------------#
# CREATES DATAFRAME FROM LOCAL EXCEL FILE AND READS TWO COLUMNS OF DATA.
data = pd.read_excel(r'[path_excel_sheet_containing_work_searches.xlsx]', sheet_name='TWC Work Search Log')
df = pd.DataFrame(data, columns= ['Date of Activity', 'Work Search Count'])
# ADD UP WORK SEARCHES FOR WEEK 1
end_date1 = date_1 + datetime.timedelta(days=6)
between_two_dates1 = (df[(df['Date of Activity']>=date_1) & (df['Date of Activity']<=end_date1)])
week1_work_searches = between_two_dates1.sum()
# ADD UP WORK SEARCHES FOR WEEK 2
date_2 = date_1 + datetime.timedelta(days=7)
end_date2 = date_2 + datetime.timedelta(days=6)
between_two_dates2 = (df[(df['Date of Activity']>=date_2) & (df['Date of Activity']<=end_date2)])
week2_work_searches = between_two_dates2.sum()
#---------------------------------------------------------------------#
#CONTINUE PAYMENT REQUEST
'''
This series of button clicks goes through the website pages, fills in
the radio buttons, and enters the work searches you've completed into
the required fields when they come up. After this is complete the
script is ended and the browser window closes.
'''
driver.find_element_by_id('addressChangeAnswer-radio.label.no').click()
driver.find_element_by_name('method:submit').click()
time.sleep(5)
driver.find_element_by_id('workOrEarnWagesWeek1-radio.label.no').click()
driver.find_element_by_id('vacationOrHolidayPayWeek1-radio.label.no').click()
driver.find_element_by_id('workOrEarnWagesWeek2-radio.label.no').click()
driver.find_element_by_id('vacationOrHolidayPayWeek2-radio.label.no').click()
driver.find_element_by_id('incomeNotAlreadyReported-radio.label.no').click()
driver.find_element_by_name('method:submit').click()
time.sleep(5)
driver.find_element_by_id('ableToWork-radio.label.yes').click()
driver.find_element_by_id('availableToAcceptWork-radio.label.yes').click()
driver.find_element_by_id('turnDownJobOffer-radio.label.no').click()
driver.find_element_by_id('turnDownJobReferral-radio.label.no').click()
driver.find_element_by_id('attendSchoolOrTraining-radio.label.no').click()
driver.find_element_by_name('method:submit').click()
time.sleep(5)
driver.find_element_by_id('workSearch.field.label.claimWeek1Contacts').send_keys(str(week1_work_searches)[21])
driver.find_element_by_id('workSearch.field.label.claimWeek2Contacts').send_keys(str(week2_work_searches)[21])
driver.find_element_by_name('method:submit').click()
time.sleep(5)
driver.find_element_by_id('certifyClaim-radio.label.yes').click()
driver.find_element_by_name('method:submit').click()
driver.quit()
def login():
driver.get('https://login.apps.twc.state.tx.us/UBS/security/logon.do')
time.sleep(5)
driver.find_element_by_id('field.label.username',).send_keys(my_username)
driver.find_element_by_id('field.label.password',).send_keys(my_password)
driver.find_element_by_name('method:logon').click()
time.sleep(5)
## Call payment_request() to start the payment request after logging in.
payment_request()
# LOGS YOU INTO TWC WEBSITE
login()