I can't figure out how to set a cookie with square brackets [] using python for Selenium. This is what I am trying:
selenium.create_cookie("test[country]=nl", "path=/, max_age=6000")
Results in:
Traceback (most recent call last): File "test.py", line 55, in test sel.create_cookie('test[country]=nl', "path=/, max_age=6000") File "C:\Python27\lib\site-packages\selenium\selenium.py", line 1813, in create_cookie self.do_command("createCookie", [nameValuePair,optionsString,]) File "C:\Python27\lib\site-packages\selenium\selenium.py", line 225, in do_command raise Exception(data) Exception: ERROR: Invalid parameter.
How can i fix this?
EDIT: This is part of the code. It is based on the code exported by the IDE.
from selenium.selenium import selenium import unittest, time, re from selenium import webdriver class country(unittest.TestCase): def setUp(self): self.verificationErrors = [] self.selenium = selenium("localhost", 4444, "*chrome", "http://example.com/") self.selenium.start() def test_country_cookie_redirect(self): sel = self.selenium sel.create_cookie('test[country]=nl', "path=/, max_age=6000") sel.open("http://example.com") self.assertEqual("http://example.com/nl/nld", sel.get_location()) def tearDown(self): self.selenium.stop() self.assertEqual([], self.verificationErrors) if __name__ == "__main__": unittest.main()
python selenium selenium-webdriver
user2511309 Sep 29 '13 at 19:22 2013-09-29 19:22
source share