-
Notifications
You must be signed in to change notification settings - Fork 0
/
automateMe.py
54 lines (37 loc) · 1.6 KB
/
automateMe.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
from selenium import webdriver
from selenium.common.exceptions import TimeoutException
from selenium.webdriver.support.ui import WebDriverWait # available since 2.4.0
from selenium.webdriver.support import expected_conditions as EC # available since 2.26.0
import sys, getopt
url = "http://www.bankofamerica.com/";
secureURl = "https://secure.bankofamerica.com/login/sign-in/entry/signOnV2.go"
failedUrl = "InvalidCredentialsExceptionV2"
successUrl = "homepage"
def getBofa(*args):
username = args[0][2]
password = args[0][3]
driver = webdriver.Firefox()
driver.get(url)
wait = lambda msg: WebDriverWait(driver, 10).until(EC.title_contains(msg))
driver.find_element_by_id("onlineId1").send_keys(username)
driver.find_element_by_id("passcode1").send_keys(password)
driver.find_element_by_id("hp-sign-in-btn").click()
wait("Bank of America")
if (driver.current_url.find(failedUrl) == -1 and driver.current_url.find(successUrl) != -1):
driver.quit()
raise Exception("Your Password or Username were incorrect!")
wait("Bank of America")
if (driver.current_url == secureURl):
raise Exception("Your identity needs to be verified. Please enter your information and try again")
wait("Accounts Overview")
balance = driver.find_element_by_xpath("//*[@id=\"Traditional\"]/li[1]/div[1]/div[1]")
print "Your Checkings Balance is " + balance.text + "."
driver.find_element_by_name("onh_sign_off").click()
driver.quit()
if __name__ == "__main__":
f = sys.argv[1]
if f == "bofa":
getBofa(sys.argv)
else:
raise Exception("No Known Command")
# https://secure.bankofamerica.com/login/sign-in/entry/signOnV2.go