#coding=utf-8
from selenium import webdriver
import time
driver=webdriver.Ie()
driver.get("http://m.mail.10086.cn")
driver.implicitly_wait(30)
driver.find_element_by_id("ur").send_keys("15610537527")
driver.find_element_by_id("pw").send_keys("15866584957")
driver.find_element_by_class_name("loading_btn").click()
#向cookie 的name 和value 添加会话信息。
driver.add_cookie({'name':'key-aaaaaaa', 'value':'value-bbbb'})
print "1、遍历所有cookie:"
#遍历cookies 中的name 和value 信息打印,当然还有上面添加的信息
for cookie in driver.get_cookies():
print "%s:%s" % (cookie['name'], cookie['value'])
print "2、输出所有cookie:"
# 获得全部cookie 信息
cookie= driver.get_cookies()
#将获得cookie 的信息打印
print cookie
print "3、输出删除指定cookie的cookie:"
# 删除一个特定的cookie
driver.delete_cookie("cookie_username")
for cookie in driver.get_cookies():
print "%s:%s" % (cookie['name'], cookie['value'])
print "4、输出删除所有cookie的cookie:"
# 删除所有cookie
driver.delete_all_cookies()
for cookie in driver.get_cookies():
print "%s:%s" % (cookie['name'], cookie['value'])
time.sleep(2)
driver.quit()