selenium自动化测试cookie操作
WebDriver操作Cookie的方法如下:
- get_cookies():获得所有Cookie
- get_cookie(name):返回字典中key为“name”的Cookie
from selenium import webdriver driver = webdriver.Chrome() driver.get("http://www.baidu.com") # 获取所有cookie信息并打印 cookie = driver.get_cookies() print(cookie)
执行结果为:
[{‘httpOnly‘: False, ‘name‘: ‘H_PS_PSSID‘, ‘path‘: ‘/‘, ‘domain‘: ‘baidu.com‘, ‘value‘: ‘1438_21121_29523_29518_29721_29567_29221_22159‘, ‘secure‘: False}, {‘httpOnly‘: False, ‘name‘: ‘BDORZ‘, ‘path‘: ‘/‘, ‘expiry‘: 1568361981.071032, ‘domain‘: ‘baidu.com‘, ‘value‘: ‘B490B5EBF6F3CD402E515D22BCDA1598‘, ‘secure‘: False}, {‘httpOnly‘: False, ‘name‘: ‘BD_UPN‘, ‘path‘: ‘/‘, ‘expiry‘: 1569139581, ‘domain‘: ‘www.baidu.com‘, ‘value‘: ‘12314753‘, ‘secure‘: False}, {‘httpOnly‘: False, ‘name‘: ‘BD_HOME‘, ‘path‘: ‘/‘, ‘domain‘: ‘www.baidu.com‘, ‘value‘: ‘0‘, ‘secure‘: False}, {‘httpOnly‘: False, ‘name‘: ‘PSTM‘, ‘path‘: ‘/‘, ‘expiry‘: 3715759227.723611, ‘domain‘: ‘baidu.com‘, ‘value‘: ‘1568275579‘, ‘secure‘: False}, {‘httpOnly‘: False, ‘name‘: ‘delPer‘, ‘path‘: ‘/‘, ‘domain‘: ‘baidu.com‘, ‘value‘: ‘0‘, ‘secure‘: False}, {‘httpOnly‘: False, ‘name‘: ‘BIDUPSID‘, ‘path‘: ‘/‘, ‘expiry‘: 3715759227.723592, ‘domain‘: ‘baidu.com‘, ‘value‘: ‘79138395196A3C2A6CA4959816433748‘, ‘secure‘: False}, {‘httpOnly‘: False, ‘name‘: ‘BD_LAST_QID‘, ‘path‘: ‘/‘, ‘expiry‘: 1568275581.723628, ‘domain‘: ‘www.baidu.com‘, ‘
相关推荐
songerxing 2020-06-11
houmenghu 2020-11-17
kentrl 2020-11-10
逍遥友 2020-10-26
jincheng 2020-09-01
Blueberry 2020-08-15
xclxcl 2020-08-03
zmzmmf 2020-08-03
阳光之吻 2020-08-03
PkJY 2020-07-08
hzyuhz 2020-07-04
89407707 2020-06-27
服务器端攻城师 2020-06-26
阳光岛主 2020-06-25
笨重的蜗牛 2020-06-20
xuanwenchao 2020-06-14
Lophole 2020-06-13
明瞳 2020-06-12