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。