This repository has been archived by the owner on May 13, 2020. It is now read-only.
/
autologin.py
56 lines (45 loc) · 1.79 KB
/
autologin.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
from selenium import webdriver
from selenium.webdriver.common.keys import Keys
import time
import os
class CbitLogin():
def __init__(self, username, password):
self.username = username
self.password = password
self.chrome_options = webdriver.ChromeOptions()
self.chrome_options.binary_location = os.environ.get(
"GOOGLE_CHROME_BIN")
self.chrome_options.add_argument("--headless")
self.chrome_options.add_argument("--disable-dev-shm-usage")
self.chrome_options.add_argument("--no-sandbox")
self.driver = webdriver.Chrome(executable_path=os.environ.get(
"CHROMEDRIVER_PATH"), chrome_options=self.chrome_options)
def closeBrowser(self):
self.driver.close()
def login(self):
try:
driver = self.driver
driver.get("https://erp.cbit.org.in/")
time.sleep(0)
user_name = driver.find_element_by_id("txtUserName")
user_name.send_keys(self.username)
next_button = driver.find_element_by_id("btnNext")
next_button.click()
time.sleep(0)
password = driver.find_element_by_id("txtPassword")
password.send_keys(self.username)
submit_button = driver.find_element_by_id("btnSubmit")
submit_button.click()
att = driver.find_element_by_id("ctl00_cpStud_lblTotalPercentage")
time.sleep(0)
print('Your attendance is :' + att.text)
att_string = att.text
self.closeBrowser()
return att_string
except:
time.sleep(5)
return "Server Down"
# login1 = CbitLogin("160118862006","160118862006")
# login1.login()
# id="ctl00_cpStud_lblTotalPercentage"
# id="ctl00_cpStud_lblTotalPercentage"