0
當我M開口我Safari
使用WebDriver
,並進入我的願望的網站總是 保存Cookies
所以是有可能打開Safari而不保存Cookies
?如何打開Safari瀏覽器,不保存的Cookie
當我M開口我Safari
使用WebDriver
,並進入我的願望的網站總是 保存Cookies
所以是有可能打開Safari而不保存Cookies
?如何打開Safari瀏覽器,不保存的Cookie
Selenium目前尚未支持以編程方式禁用Safari中的Cookie。你必須手動禁用它。您可以嘗試以下方法:
1.編寫將從Safari文件夾中刪除所有文件的代碼。事情是這樣的:
def clearCache():
"""This will just delete the files straight from the safari folder, guarentee a clean start"""
try:
#Using rm command assuming you are using MacOS
os.system("rm -rf $HOME/Library/Safari/LocalStorage/*.localstorage")
except Exception, e:
log.error("Error in clearCache: %s" %e)
2.或者你也可以手動設置禁用cookie爲特定的配置文件,然後使用該配置文件來啓動你的Safari瀏覽器的webdriver。