[selenium ]selenium 自动登录考勤系统

来源:互联网 发布:什么是oracle元数据 编辑:程序博客网 时间:2024/05/21 17:07

使用selenium 的python包,然后实现了简单的自动登录和查看所需的页面。

脚本写起来很简单,需要会使用浏览器的debug功能,分析下页面结构。这个例子只是简单参考,应该无法运行,因为是内部系统。。



# -*- coding: utf-8 -*-#get_info_of_working.py   python2.7.x#orangleliu@gmail.com    2014-04-24'''用来自动打开查询工时的界面 直接看到自己最近的打卡情况'''from selenium import webdriverfrom selenium.webdriver.common.keys import Keysdef  login_system(driver):    '''    登陆到考勤管理系统    '''    login_url = 'http://att.xx.com/'    username = 'zhizhi.liu'    password = '1234'    driver.get(login_url)    driver.find_element_by_id("username").clear()    driver.find_element_by_id("username").send_keys(username)    driver.find_element_by_id("password").clear()    driver.find_element_by_id("password").send_keys(password)    driver.find_elements_by_tag_name("form")[0].submit()    driver.get('http://att.xx.com/TRecordList.action')if __name__ == "__main__":    driver = webdriver.Firefox()    login_system(driver)

0 0
原创粉丝点击