相关疑难解决方法(0)

如何使用python在selenium webdriver中将cookie设置为特定域?

您好,StackOverflow用户.我试图实现的是防止在我的测试打开主页时弹出恼人的帮助盒.到目前为止,这是我用来打开主页面的方法:

def open_url(self, url):
    """Open a URL using the driver's base URL"""
    self.webdriver.add_cookie({'name' : 'tour.index', 'value' : 'complete', 'domain' : self.store['base'] + url})
    self.webdriver.add_cookie({'name' : 'tour.map', 'value' : 'complete', 'domain' : self.store['base'] + url})
    self.webdriver.get(self.store['base'] + url)
Run Code Online (Sandbox Code Playgroud)

但是,运行测试后返回的是:

2014-07-23 15:38:19.453057: X Message: u'You may only set cookies for the current domain' ;
Run Code Online (Sandbox Code Playgroud)

在实际加载基本测试域之前,如何设置cookie?

python cookies firefox selenium

13
推荐指数
1
解决办法
2万
查看次数

标签 统计

cookies ×1

firefox ×1

python ×1

selenium ×1