Skip to content
This repository has been archived by the owner on Nov 29, 2018. It is now read-only.

IEDriver broken cookie management #4307

Closed
lukeis opened this issue Mar 3, 2016 · 23 comments
Closed

IEDriver broken cookie management #4307

lukeis opened this issue Mar 3, 2016 · 23 comments

Comments

@lukeis
Copy link
Member

lukeis commented Mar 3, 2016

Originally reported on Google Code with ID 4307

Scenario:
Any scenario that includes getting/setting cookies using InternetExplorerDriver.manage().addCookie/setCookie.

Scenario in given simplified test case:
1. Opens Google home page.
2. Tries to set dummy cookie.
3. Reloads the page.
4. Tries to get the previously set cookie.

Code here: https://gist.github.com/db78b0301b28e1b920f0

Should pass the tests, instead it fails:
• the first test — with «org.openqa.selenium.WebDriverException: Unable to add cookie
to page»;
• the second test — with java.lang.NullPointerException (getCookieNamed returns null).

Code works fine if run with FirefoxDriver, OperaDriver and ChromeDriver.

Selenium version: 2.25.0
OS: Windows 7 Ultimate x64 SP1
Browser: Internet Explorer 9
Browser version: 9.0.8112.16421 32-bit
Webdriver version: 2.25.2.0 32-bit
Java version: 1.6.0_24

Reported by Actinate on 2012-07-25 13:49:06

@lukeis
Copy link
Member Author

lukeis commented Mar 3, 2016

Hi,

sorry but i can not reproduce this issue at least at my configuration: Vista+IE9+32b.

Could you repeta the problem with IE driver debug log?
Here is an example of setup such log https://gist.github.com/3176482
Maybe it helps to understand why it's happened.

Reported by a.u.savchuk on 2012-07-25 14:37:47

@lukeis
Copy link
Member Author

lukeis commented Mar 3, 2016

Hello,

Thanks. Here's the log. Well, line 396 is suspicious (Unable to add cookie, document
does not appear to be an HTML page)

Reported by Actinate on 2012-07-25 15:10:41


- _Attachment: [iedriver1.log](https://storage.googleapis.com/google-code-attachments/selenium/issue-4307/comment-2/iedriver1.log)_

@lukeis
Copy link
Member Author

lukeis commented Mar 3, 2016

I played with it a bit and here's what I figured out. There may be problems with parsing
cookie files. I've set a breakpoint in the second test and looked at getCookies() —
there was one item. IE's devtools report there to be two cookie items. In the project
I'm actually testing getCookies() also return a list of two or three items, whereas
six are actually set.

Reported by Actinate on 2012-07-25 15:18:57

@lukeis
Copy link
Member Author

lukeis commented Mar 3, 2016

Hi,

thanks. i think it'll help. Major lines, imho, are:
-------------------------------------------------------------------
T 2012-07-25 18:06:20:189 DocumentHost.cpp(253) Entering DocumentHost::AddCookie
...
T 2012-07-25 18:06:20:198 DocumentHost.cpp(310) Entering DocumentHost::IsHtmlPage
...
D 2012-07-25 18:06:20:199 DocumentHost.cpp(329) Unable to support custom document type:
Opera.Protocol
...
W 2012-07-25 18:06:20:200 BrowserFactory.cpp(589) RegQueryValueEx failed for retrieving
required buffer size
W 2012-07-25 18:06:20:200 DocumentHost.cpp(359) Unable to read mime type from registry
for document type
W 2012-07-25 18:06:20:200 DocumentHost.cpp(266) Unable to add cookie, document does
not appear to be an HTML page
-------------------------------------------------------------------

For it looks like Opera is installed or was be installed, maybe as default browser.
If IE is not "default", it's tried to check content of HKEY_CLASSES_ROOT/.htm element.
Usually there is string, i.e. <XXX> which can be used to get content of another HKEY_CLASSES_ROOT/<XXX>
element
which contains something like document type, i.e. for me they are "FirefoxHTML" and
"Firefox HTML Document".
From last got value we try to determine is it HTML page (opened by HTML processing
program) or not.

Found error said about it can not find HKEY_CLASSES_ROOT/Opera.Protocol, don't know
why.

Could you describe which browseres are installed at your machine, which is default?
Looks like yet another trick for Opera is required at DocumentHost::isHTMLPage().

But, it's for someone who will fix it, i really don't understand for which purpose
it is still required? It has trick for IE, FF and looks like will for Opera.

I hope it helps.

Reported by a.u.savchuk on 2012-07-25 19:06:15

@lukeis
Copy link
Member Author

lukeis commented Mar 3, 2016

Thanks again. Yes, Opera is my default browser. It's weird, imo, that it causes such
error.

The following browsers are installed on my system:
• Internet Explorer 9 (32- and 64-bit);
• Opera 12.0 (default);
• Mozilla Firefox 10.02 (started updating right now :) );
• Google Chrome 20.0.1132.57
  and Google Chrome Canary 22.0.1217.0;

Concerning the tricks you mentioned. Does that mean that if I want to test for IE,
I need to keep it (or FF) a default browser? If that's a solution, well, humbly I think
this should be fixed so that running any webdriver does not depend on default browser
(document type *description*).

Can't it be checked by mimetype (text/html)?

Reported by Actinate on 2012-07-25 20:40:26

@lukeis
Copy link
Member Author

lukeis commented Mar 3, 2016

Thanks for information.

No, you don't need to setup tested browser as default. I just described how it works
at selenium level. Potentially all browsers configuration should be supported, imho.
Just for info - could you check workaround - settin gup tested IE as default and run
the same test - is it helped? 

Yes, it can be checked in other way at selenium level.
I think, someone from project members will fix it. I'm only helping with investigation
of issue reason and getting additional information.

Reported by a.u.savchuk on 2012-07-26 08:30:22

@lukeis
Copy link
Member Author

lukeis commented Mar 3, 2016

Okay. Yes, really, with either IE or Firefox or Chrome set up as default, the test runs
successfully. Having Opera set up as default makes the test fail.

Thank you for your help a.u.savchuk. Do I need to take any further steps so that Selenium
devs see this issue, or they just gonna visit this topic eventually? (I'm first time
to issue trackers, you know *blush*)

Reported by Actinate on 2012-07-26 10:52:35

@lukeis
Copy link
Member Author

lukeis commented Mar 3, 2016

Reported by david.burns@theautomatedtester.co.uk on 2012-07-26 13:43:15

  • Labels added: Browser-IE, Component-WebDriver
  • Labels removed: Status-Untriaged

@lukeis
Copy link
Member Author

lukeis commented Mar 3, 2016

Could you re-run your test with the latest private release of the IEDriverServer.exe?
I've updated the logging for getting values from the registry which should help diagnose
this a little further. You can get the latest 32-bit private release from http://selenium.googlecode.com/svn/trunk/cpp/prebuilt/Win32/Release.

Reported by james.h.evans.jr on 2012-07-26 15:21:19

@lukeis
Copy link
Member Author

lukeis commented Mar 3, 2016

Done. However I diffed the logs — no much difference. Opera is set up as default again.

If you need registry values alone, I can provide them. In fact, they're pretty much
the same as if FF was default, except the word Opera instead of Firefox.

Reported by Actinate on 2012-07-26 15:52:53


- _Attachment: [iedriver2.log](https://storage.googleapis.com/google-code-attachments/selenium/issue-4307/comment-10/iedriver2.log)_

@lukeis
Copy link
Member Author

lukeis commented Mar 3, 2016

You should have seen additional logging around the registry retrieval. Did you download
from the above link, or did you go through either the SeleniumHQ website or http://code.google.com/p/selenium/downloads/list?
The additional logging hasn't been pushed to be publicly available yet; you'll have
to get the prebuilt server directly from the source tree in Subversion. The link in
comment 9 is a web view of that repository.

Reported by james.h.evans.jr on 2012-07-26 17:30:15

  • Status changed: NeedsClarification

@lukeis
Copy link
Member Author

lukeis commented Mar 3, 2016

I have downloaded IEDriverServer.exe from the index you linked to, replaced my old IEDriverServer.exe
with this one and rerun the tests. Then attached the log. Do I need to do any other
actions except that? Just in case I have to rebuild something from source, I fear I
won't be able to do this. I'm a complete newborn.

Reported by Actinate on 2012-07-26 17:35:51

@lukeis
Copy link
Member Author

lukeis commented Mar 3, 2016

(however, I'm not that stupid :) )

Reported by Actinate on 2012-07-26 17:44:33

@lukeis
Copy link
Member Author

lukeis commented Mar 3, 2016

This issue was closed by revision r17591.

Reported by james.h.evans.jr on 2012-07-26 21:30:39

  • Status changed: Fixed

@lukeis
Copy link
Member Author

lukeis commented Mar 3, 2016

I am having this issue with selenium node 2.33, iedriver 2.35.  Attached is the IEDriver
log.  Was this re-broken?

Reported by ricardo.j.lopez on 2013-08-21 18:16:41


- _Attachment: [IEDriverServer.log](https://storage.googleapis.com/google-code-attachments/selenium/issue-4307/comment-15/IEDriverServer.log)_

@lukeis
Copy link
Member Author

lukeis commented Mar 3, 2016

@ricardo.j.lopez 

Please raise new issue with:
* full executable test script
* IE browser information
* OS information
* IEDriverServer.log with TRACE level

Reported by a.u.savchuk on 2013-08-28 12:36:15

@lukeis
Copy link
Member Author

lukeis commented Mar 3, 2016

I've been seeing the issue as well - Ie10, Windows 7, IedriverServer  64-bit (dec 5th
2013 version) and selenium standalone server 2.38.0.. 

For the people at our office here, it appears that they can run the tests in their
local IE instances, but if they attempt to run using sauceLabs or remoteWebDriver,
the cookies don't get set at all.

We've tried adding cookies the "usual" route and also thru javascript - but neither
seem to do the trick.


Reported by polaire on 2013-12-14 00:47:43


- _Attachment: [server.log](https://storage.googleapis.com/google-code-attachments/selenium/issue-4307/comment-18/server.log)_

@lukeis
Copy link
Member Author

lukeis commented Mar 3, 2016

I have the same problem too. Unable to set cookie. Is there a fix?

ie9 32bit. Selenium 2.37. iedriver 2.38.

Please see the attached file. Thanks!

Reported by gthia.GT on 2014-01-13 15:28:13


- _Attachment: [iedriver1.log](https://storage.googleapis.com/google-code-attachments/selenium/issue-4307/comment-19/iedriver1.log)_

@lukeis
Copy link
Member Author

lukeis commented Mar 3, 2016

I'm afraid the logs attached to the comments do not match what the comments say are
being run. The log in comment 18 shows running 2.31.0.0 of IEDriverServer.exe; the
log attached to comment 19 shows running 2.28.0.4. The fix for this issue wasn't applied
until 2.37.0.1, in revision 334d39caf93. Please retest with at least that version,
and re-post your logs.

Reported by james.h.evans.jr on 2014-01-29 23:24:55

@lukeis
Copy link
Member Author

lukeis commented Mar 3, 2016

I'm unable to get any cookies it seems with IE.  The same code works fine with FF. 
Just a simple getDriver.manage.getCookies returns nothing in IE.  using 2.35

Reported by wjcheng on 2014-02-21 03:12:45

@lukeis
Copy link
Member Author

lukeis commented Mar 3, 2016

execute javascript for setting cookies with protective mode on.

Reported by veeresh.hubballi on 2014-06-05 22:43:23

@lukeis
Copy link
Member Author

lukeis commented Mar 3, 2016

Hope we could fix it without having to do some workaround in JS just due to an HTTP
header 'cache-control: no-cache' with IE9, selenium server 2.42.2 and IEdriver 2.42.0.
See this issue which is maybe related :
https://code.google.com/p/selenium/issues/detail?id=6985#c9

Thanks

Reported by yannick.chabbert on 2014-09-04 19:06:59

@lukeis
Copy link
Member Author

lukeis commented Mar 3, 2016

Reported by luke.semerau on 2015-09-17 18:15:52

  • Labels added: Restrict-AddIssueComment-Commit

@lukeis lukeis closed this as completed Mar 3, 2016
@SeleniumHQ SeleniumHQ locked and limited conversation to collaborators Mar 4, 2016
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

1 participant