2015-11-05 77 views

回答

0

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。

Source

相关问题