I am trying to set cookies on Internet Explorer from a Cucumber acceptance test.
Here is the first thing that I tried:
browser.cookies.add("my.cookie","90",{:path => "/", :expires => expiredTime})
Here is the second thing:
browser.driver.manage.add_cookie(name:"my.cookie", value:"90", expires:expired_time)
Both of these approaches cause the same exception:
(Selenium::WebDriver::Error::NoSuchDocumentError) Unable to add cookie to page
I only get this exception when using Internet Explorer, but not Firefox.
I am using Windows 7, IE 8, 64-bit.
Some of my gems: selenium-webdriver (2.25.0) watir-webdriver (0.6.1) cucumber (1.2.1)
Thanks in advance for any advice on fixing this issue.
I had exactly the same issue on Win7 / IE9. I figured out that adding the cookies failed when the page the browser was on had no-cache headers set. We created an empty page on our server with far-future cache headers, and setting cookies while on that page works.
I do not know which particular header prevents adding cookies. Since you probably need to move to a different page to set the cookies, it's worth using one with far-future headers to speed up loading.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.