1

I'm having a problem here with authorization on a site. I'm using a headless browser PhantomJS on top of Selenium. What I do:

driver.get('https://foo.com')
# some instructions to log in
# foo.com makes some requests to https://bar.foo.com and sets cookies for https://bar.foo.com domain
driver.get_cookies()
# no cookies for https://bar.foo.com
# any requests to https://foo.com are not autorized because the cookies from https://bar.foo.com are the ones that are needed, but not provided

Is there any workaround for it? Been searching to fix the problem for a long time and no success.

One more note: for example, chromedriver collects all of the cookies received from AJAX requests to subdomains, while phantomjs doesn't do that.

Berman
  • 143
  • 11
  • Maybe [this](http://stackoverflow.com/questions/15058462/how-to-save-and-load-cookies-using-python-selenium-webdriver) can help you. – ᴀʀᴍᴀɴ Jan 05 '17 at 15:42
  • Thank you for the answer, but it's not what I need. Even if I collect all the cookies from both foo.com and bar.foo.com, selenium won't include any cookies from bar.foo.com when getting pages from foo.com, thus the requests won't be authorized. – Berman Jan 05 '17 at 15:45
  • http://stackoverflow.com/questions/41423699/i-cannot-get-access-to-the-second-page-by-using-phantomjs-automation/41427130#41427130 –  Jan 05 '17 at 16:23
  • cookies file is created by phantomjs bidings for python by default. https://github.com/SeleniumHQ/selenium/blob/master/py/selenium/webdriver/phantomjs/service.py I don't want to get the cookies from the subdomain, I want to get them delivered to the main domain. – Berman Jan 05 '17 at 17:00

0 Answers0