You're attempting to use Selenium's cookie adding functionality to set cookies in IE. Your requests to add a cookie fail with the error
"=> Unable to add cookie to page (WARNING: The server did not provide any stacktrace information)"
There’s a known issue with Selenium and IE where attempts to set cookies fail because Selenium tries to check the MIME type of the document before adding a cookie, and for reasons unknown to the Selenium project, that check fails.
There doesn’t appear to be one set solution; This problem appears to have a few causes. People have reported that it’s been fixed by:
- ensuring the web server that’s serving the page is not setting the header ‘Cache-Control: no-cache’
- ensuring the web server that’s serving the page is not setting the header ‘Pragma: no-cache’
- ensuring that the default browser on the machine running the Selenium-controller browser is not Opera
- A patch to Selenium — https://code.google.com/p/selenium/source/detail?r=511ac59049bc
And, in this issue, someone reports that it is still happening: https://code.google.com/p/selenium/issues/detail?id=6985#c9
On our IE VMs, Opera is not the default browser, so that's not the cause of the problem. You can try checking the cache & pragma headers your server is sending; This is something you’ll have to do on your test server (If you're not sure what this means, ask the team responsible for developing or hosting your app).
You can also try specifying the newer version of IEDriver (as shown here) and adding the desired capability which disables MIME checks when setting cookies ('ie.validateCookieDocumentType', set to true). But people are reporting that this does not work.
The Most Reliable Workaround
This means your script should still run across all platforms, without needing special IE9 changes:
## Ruby Example -- Please use your language's Selenium Bindings driver.execute_script ‘document.cookie=“username=John; path=/”;’