py+webdriver学习之旅10:字典

__author__ = 'Administrator'

from selenium import webdriver
import os,time
#coding=gbk

def zidian():
    d={'fnngj':'a23456','testing360':123456}
    print "suess read username and password!!"
    return d

for k,v in zidian().items():
    driver = webdriver.Firefox()
    driver.get("http://www.baidu.com")
    time.sleep(3)
    driver.find_element_by_name("tj_login").click()
    driver.find_element_by_id("user_name").clear()
    driver.find_element_by_id("user_name").send_keys(k)
    time.sleep(3)
    driver.find_element_by_id("user_pwd").clear()
    driver.find_element_by_id("user_pwd").send_keys(v)
    time.sleep(3)
    driver.find_element_by_id("dl_an_submit").click()
    time.sleep(1)
    driver.close()

  

posted @ 2015-01-13 20:08  Mr.Dantes  阅读(144)  评论(0编辑  收藏  举报