1

[Quoting from a similar question] I have searched throughout the internet but none of the answers I found have a clear solution.

I am using selenium webdriver with Python.

My test needs to verify when you save your login information and close the browser and reopen it then those credentials remain and are saved on a new session. So I want to close the current session and reopen it in order to verify if a cookie persists on the page however Selenium deletes all stored session data so the test case will always fail. Is there any way to prevent Selenium from deleting the stored session data after closing the browser for the specific test case?

When I do run it I get a no such session error.

My current code block ex:


desired_cap = { 'loggingPrefs' : { 'browser' : 'ALL' },
'chromeOptions': { 'binary' : ApplicationExePath}}
.
.
.
self.driver = webdriver.Chrome(self.chrome_driver_path,desired_capabilities= desired_cap,service_args=chromedriver_service_args)

Scenario : I have an application which uses Chromium Embidded Framework. As a part of that, I want to check the login persistence i.e login in the app -> Close the app -> Launch the app -> Check if login persists

Issue : On closing the app and relaunching it, the login info doesn't persists! (This is done via selenium...)

Jamie Eltringham
  • 810
  • 3
  • 16
  • 25
Suyash
  • 11
  • 1
  • Possible duplicate of [Load Chrome Profile using Selenium WebDriver](http://stackoverflow.com/questions/14480717/load-chrome-profile-using-selenium-webdriver) – SiKing Mar 03 '16 at 15:38
  • I am not sure. I came to know that I have to add user-data-dir = 'C:\Users\suyasha\AppData\Local\Google\Chrome\User Data\Profile 1' so that I can persist the login info. Is it? – Suyash Mar 03 '16 at 16:19
  • Selenium, by default, will launch the browser with a **new** profile each time. So you have to: launch browser - login - save profile - exit browser - launch browser - restore profile - check that login persists. – SiKing Mar 03 '16 at 16:23
  • You could also simplify your test case by just: login - check that a cookie is stored. Anything more and you are no longer testing your app, you are testing functionality of the browser. – SiKing Mar 03 '16 at 16:25
  • Yes, this seems to be a better process flow. Can you please share a link for reference so that I can get a hold of how to save a profile (Python + Selenium). – Suyash Mar 04 '16 at 06:19

0 Answers0