-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.py
40 lines (33 loc) · 1.04 KB
/
main.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
from selenium import webdriver
from selenium.webdriver.common.keys import Keys
import time
from selenium.webdriver.chrome.service import Service
from webdriver_manager.chrome import ChromeDriverManager
from selenium.webdriver.common.by import By
from .credential import username, password, url
op = webdriver.ChromeOptions()
op.add_argument('headless')
s=Service(ChromeDriverManager().install())
driver = webdriver.Chrome(options=op, service=s)
# Login Page
driver.get(url)
time.sleep(2)
username_field = driver.find_element(By.ID, 'UserLogin_username')
username_field.send_keys(username)
password_field = driver.find_element(By.ID, 'UserLogin_password')
password_field.send_keys(password)
password_field.send_keys(Keys.RETURN)
time.sleep(2)
skip = driver.find_element(By.CLASS_NAME, 'skip_pulse')
if skip.text != "":
skip.click()
# clockin
clockin_btn = driver.find_element_by_id('attendance-logger-widget')
clockin_btn.clear()
time.sleep(2)
#Signout
driver.get(url + "/user/logout")
time.sleep(1)
#Close Chrome
driver.quit()
print('berhasil yes')