Selenium自动登录考勤系统-自动化测试
更新时间:2022-05-10 09:09:15 作者:多测师 浏览:229
使用selenium 的python包,然后实现了简单的自动登录和查看所需的页面。脚本写起来很简单,需要会使用浏览器的debug功能,分析下页面结构。这个例子只是简单参考,应该无法运行,因为是内部系统。
# -*- coding: utf-8 -*-
#get_info_of_working.py python2.7.x
#orangleliu@gmail.com 2014-04-24
'''''
用来自动打开查询工时的界面 直接看到自己最近的打卡情况
'''
from selenium import webdriver
from selenium.webdriver.common.keys import Keys
def 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)
以上内容为大家介绍了自动化测试中的Selenium自动登录考勤系统,本文由多测师亲自撰写,希望对大家有所帮助。了解更多自动化测试相关知识:https://www.aichudan.com/xwzx/