a python program for auto check in to work on web site
selenium need other browser driver
# -*- coding: utf-8 -*-import time
import random
from selenium import webdriver
from selenium.webdriver.common.keys import Keys
driver = webdriver.Chrome() # Optional argument, if not specified will search path.driver.get('company url')
# random time login(10s-30min
time.sleep(random.randint(10,1800)) # Let the user actually see something!
try:
# find xpath of account & password driver.find_element_by_xpath("//*[@id='userid_input']").send_keys("account")
driver.find_element_by_xpath("//*[@id='password']").send_keys("password")
# click login button driver.find_element_by_xpath("/html/body/form/table[2]/tbody/tr/td[2]/table/tbody/tr[3]/td[2]/div/a/img").click()
time.sleep(5)
# click login page driver.find_element_by_link_text("今日出勤班別").click()
time.sleep(10)
# change browser page
windows = driver.window_handles driver.switch_to.window(windows[-1])
# click Attendance button
driver.find_element_by_xpath("//*[@id='button_save']").click()
time.sleep(5)
print("簽到成功")
except:
print("簽到失敗")
#driver.quit()
留言
張貼留言