-
Notifications
You must be signed in to change notification settings - Fork 2
/
MyFCULogin.py
66 lines (59 loc) · 2.53 KB
/
MyFCULogin.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
from selenium import webdriver
from selenium.common.exceptions import NoSuchElementException
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.support.ui import Select
import os
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait
from time import sleep
import ddddocr
import base64
mainUrl = "https://myfcu.fcu.edu.tw/main/InfoMyFcuLogin.aspx"
import configparser
from selenium.webdriver.support import expected_conditions as EC
config = configparser.ConfigParser()
config.read('config.ini')
chrome_options = webdriver.ChromeOptions()
chrome_options.add_experimental_option('excludeSwitches', ['enable-logging'])
browser = webdriver.Chrome(chrome_options=chrome_options)
browser.maximize_window()
def login():
browser.get(mainUrl)
sleep(1.5)
browser.find_element_by_xpath(
'//*[@id="txtUserName"]').send_keys(config['data']['user'])
sleep(1.5)
browser.find_element_by_xpath(
'//*[@id="txtPassword"]').send_keys(config['data']['pass'])
sleep(1.5)
browser.find_element_by_xpath(
'//*[@id="OKButton"]').click()
browser.execute_script("document.getElementsByClassName('barbtn')[0].click();")
sleep(1.5)
browser.execute_script("document.getElementsByClassName('icon-block text ng-binding')[4].click();")
sleep(1.5)
browser.execute_script("document.getElementsByClassName('ng-scope')[69].click();")
sleep(1.5)
strScript = 'window.open("'+mainUrl+'");'
browser.execute_script(strScript)
sleep(1.5)
windows=browser.window_handles
browser.switch_to.window(windows[-1])
sleep(1.5)
browser.find_element_by_xpath(
'//*[@id="txtPassword"]').send_keys(config['data']['pass'])
sleep(1.5)
browser.find_element_by_xpath(
'//*[@id="OKButton"]').click()
sleep(1.5)
browser.execute_script("document.getElementsByClassName('barbtn')[0].click();")
sleep(1.5)
browser.execute_script("document.getElementsByClassName('icon-block text ng-binding')[3].click();")
sleep(1.5)
browser.execute_script("document.getElementsByClassName('ng-scope')[76].click();")
#browser.find_element_by_xpath('/html/body/div/div[3]/div/ul/li[10]').click()
#browser.execute_script("document.getElementsByClassName('li nav-item ng-scope active')[0].click();")
#browser.find_element_by_xpath('/html/body/div/div[3]/div/ul/li[10]/a').click()
#browser.execute_script("document.getElementsByClassName('nav-link ng-binding')[9].click();")
if __name__ == "__main__":
login()