TA的每日心情 | 无聊 2018-5-10 09:16 |
---|
签到天数: 172 天 连续签到: 2 天 [LV.7]测试师长
|
python+selenium自动登陆UI自动化实例
刚入门写了一个简单的登陆,希望能和大家相互交流
#!/usr/bin/env python
#_*_coding:utf-8_*_
import time
def login1(username,password):
from selenium import webdriver
driver=webdriver.Firefox()
url='http://hxtest.51tv.com/aibb'
driver.get(url)
time.sleep(2)
driver.maximize_window()
time.sleep(2)
driver.find_element_by_partial_link_text('登录').click()
time.sleep(2)
#driver.set_window_size(540,960)
driver.find_element_by_id('zhanghao').send_keys(username)
time.sleep(1)
driver.find_element_by_id('password').send_keys(password)
time.sleep(2)
driver.find_element_by_class_name('btns').click()
time.sleep(2)
#driver.close()
driver.quit()
login={'test02':'123456',
'test03':'123456'
}
for username,password in login.items():
login1(username,password)
|
|