selenium "Can only set Cookies for the current domain"

使用selenium插入cookie時

driver.add_cookie(cookie)

出現 Can only set Cookies for the current domain

原因是當前域與cookie作用域不同,

只需要在插入之前訪問一下cookie作用域下的域名即可

driver.get(url)
driver.add_cookie(cookie)

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章