Allow specifying path for storing cookies#547
Conversation
jesg
left a comment
There was a problem hiding this comment.
thanks for working on this. looks like a good addition to ghostdriver.
i need two changes to accept this feature.
-
the default case should be backwards compatible
-
basic unit test to verify this actually sets cookies
| _currentWindowHandle = null, | ||
| _cookieJar = require('cookiejar').create(), | ||
| _cookieJar, | ||
| _cookiePath = null, |
There was a problem hiding this comment.
the default should be an empty string to be consistent with the phantomjs source. though i'd prefer to be conservative and pass no arguments when this option is not used.
src/session.js
Outdated
| _cookiePath = desiredCapabilities['phantomjs.cookies.path']; | ||
| _negotiatedCapabilities['phantomjs.cookies.path'] = _cookiePath; | ||
| } | ||
| _cookieJar = require('cookiejar').create(_cookiePath); |
There was a problem hiding this comment.
the default case should be the same. require('cookiejar').create()
|
Thanks for the feedback. I've fixed the behavior when the path is not set, and added the test case. |
|
@kasatani the test to run the test: you may need to modify |
|
CookieStoreTest passes in my environment. Which version of phantomjs should I use for the testing? I'm using the released phantomjs-2.1.1 on macOS Sierra. |
i normally use a patched version of 2.1.1 but i'm also seeing the error in the official 2.1.1 release. i run the tests on ubuntu 17. i should be able to take a look on a mac sometime next week. |
In current implementation of ghostdriver there is no way to load cookies when starting a session. Passing --cookies-file to phantomjs doesn't work because ghostdriver's session.js creates a new cookie jar without any argument, which doesn't allow us to load or save cookies.
I have added "phantomjs.cookies.path" capability that lets you specify the path for the cookie jar.