我需要帮助。我在pycharm中有以下代码:
def cookie(self):
self.login(self.config.username, self.config.password, select_device=False, remember_me=True)
self.driver.get(self.config.main_page)
pickle.dump(self.driver.get_cookies(), open("cookies.pkl", "wb"))
url = self.driver.current_url
self.driver.close()
self.new_browser(url)
cookies = pickle.load(open("cookies.pkl", "rb"))
for cookie in cookies:
print cookie
self.driver.add_cookie(cookie)
self.driver.get(self.config.main_page)
但是我收到以下错误消息:
'消息:您只能为当前域设置cookie \ nStacktrace:\ n在FirefoxDriver.prototype.addCookie中提供:\ n文件:/// c:/ users / dember / appdata / local / temp / tmprudc2u / webdriver-py-profilecopy/extensions/fxdriver@googlecode.com/components/driver-component.js:9750:1)\ n在DelayedCommand.prototype.executeInternal_ / h(文件:/// c:/ users / dember / appdata) /local/temp/tmprudc2u/webdriver-py-profilecopy/extensions/fxdriver@googlecode.com/components/command-processor.js:11635:16)nn在DelayedCommand.prototype.executeInternal_(file:/// c:/ users /dember/appdata/local/temp/tmprudc2u/webdriver-py-profilecopy/extensions/fxdriver@googlecode.com/components/command-processor.js:11640:7)\ n在DelayedCommand.prototype.execute /< (文件:/// C:/users/dember/appdata/local/temp/tmprudc2u/webdriver-py-profilecopy/extensions/fxdriver@googlecode.com/components/command-processor.js:11582:5)
如果我从pywin步骤通过setp运行它,如问题15058462(How to save and load cookies using python selenium webdriver),它可以正常工作。
谁能帮助我吗? 感谢