Skip to content
This repository has been archived by the owner on May 30, 2023. It is now read-only.

Arg '--cookies-file' broken on 2.0 #13115

Closed
juanchristian opened this issue Mar 28, 2015 · 13 comments
Closed

Arg '--cookies-file' broken on 2.0 #13115

juanchristian opened this issue Mar 28, 2015 · 13 comments
Labels

Comments

@juanchristian
Copy link

I was trying this simple code using 2.0:

from selenium.webdriver.phantomjs import webdriver

driver = webdriver.WebDriver(service_args=['--cookies-file=cookies.txt'])
driver.get('http://google.com')
driver.quit()

The 'cookies.txt' file wasn't being created, tried many times, no lucky. Downgraded to 1.9.8 and bang, working 100%

@yali25
Copy link

yali25 commented Mar 30, 2015

Hi,

I encountered the same issue. By changing one line in the "phantom.cpp" file I got it working, but I'm not sure if this is the correct way to do it (or if it will break existing code).

Change the the line in the Phantom::createCookieJar method from:
return new CookieJar(filePath, this);

to

return new CookieJar(m_config.cookiesFile() != "" ? m_config.cookiesFile() : filePath,this);

@vitallium
Copy link
Collaborator

Are you sure? Because I don't see that line in phantom.cpp.

@yali25
Copy link

yali25 commented Mar 30, 2015

@juanchristian
Copy link
Author

Yes, maybe manually modifying the source can fix the issue. But people behind PhantomJS need to fix that!

@kunzhipeng
Copy link

I met the same problem. 1.9.8 does working!

@chunfengd
Copy link

I have the same problem.

@maZahaca
Copy link

maZahaca commented May 7, 2016

+1, Does anybody can fix it?

@vitallium
Copy link
Collaborator

Perhaps there is a problem with Ghostdriver. Because the plain PhantomJS script works.

@Yossi
Copy link

Yossi commented May 31, 2016

This is at line 310 now.

@jantman
Copy link

jantman commented Mar 29, 2017

I'm running into some serious issues because of this, and I would've expected functionality like this to be much more visible, and problematic for a lot of users. Is there perhaps some workaround I'm not aware of?

@Yossi
Copy link

Yossi commented Mar 29, 2017

The "workaround" is to compile it yourself after fixing the code the way @yali25 suggests.

Here's a wiki page with step by step instructions https://github.com/Yossi/agent-stats-utils/wiki/How-to-compile-phantomjs-for-yourself

@jantman
Copy link

jantman commented Apr 2, 2017

That "workaround" may be suitable for things that only use phantomjs locally, but it's certainly not for the acceptance tests of my open source project, which have to run on TravisCI as well as on the local machine of anyone who wants to develop the project.

For anyone else who has similar needs, I have come up with a workaround the solves the problem if your environment requires phantomjs, but has no control over the version or compilation. I'm using Selenium WebDriver in my tests, to wrap phantomjs. I've written some wrapper methods that are called to get a Browser instance and to request pages; after a page is requested (before teardown), I use WebDriver's get_cookies() method to retrieve a list/array of cookies and then serialize that to disk as JSON. When a new Browser is constructed and a page is first loaded, I deserialize the JSON and use add_cookie() to inject the cookies back into phantomjs. As far as I can tell, this works with any phantomjs version (and in theory should work with any other WebDriver-supported browser as well).

@stale stale bot added the stale label Dec 26, 2019
@stale
Copy link

stale bot commented Dec 29, 2019

Due to our very limited maintenance capacity, we need to prioritize our development focus on other tasks. Therefore, this issue will be automatically closed (see #15395 for more details). In the future, if we see the need to attend to this issue again, then it will be reopened. Thank you for your contribution!

@stale stale bot closed this as completed Dec 29, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

8 participants