This repository was archived by the owner on Nov 29, 2018. It is now read-only.
-
- Notifications
You must be signed in to change notification settings - Fork 195
This repository was archived by the owner on Nov 29, 2018. It is now read-only.
Allow for reuse of the temporary profile, in order to realistically test persistant browser cookies. #1954
Copy link
Copy link
Open
Description
Originally reported on Google Code with ID 1954
The test scenario: Creating test cases which test login "Remember me" functionality. A user of a web site, that has authentication, can choose to store a persistent cookie, which will allow them to forgo entering their credentials on subsequent visits. The persistent cookie has an expiration. A typical manual test case for this would be to do these steps for each of the browsers you support: 1. Start the browser, clear cookies, history, cache, etc. 2. Login to the website, choosing "Remember me?", and accepting the persistent cookie. 3. Shut down the browser completely. 4. Start the browser, which still contains the stored cookie. 5. Go to the website, and see that you are logged in automatically, without having to authenticate with username/password. In Python WebDriver (and likely the other webdriver clients, and in Selenium RC as far as I know), the temporary profile gets deleted when the browser session is shut down. An automation technique that one might do, would be to collect the cookie value into a variable when it gets created, then after the browser is shut down, and restarted with a new clean profile, then set the cookie via the automation code, navigate the browser to the website, and test the auto-login. This would simulate the persistent cookie, but not be the same as truly testing the browser's ability to store the persistent cookie. Case in point: The website sets the expiration via the cookie 'Max-Age' attribute, which is supported in Firefox, and many other browsers. However, Internet Explorer, all the way through IE9, does not support the 'Max-Age' attribute. IE expects the 'expires' attribute to be used, in order to set a persistent cookie with an expiration. A cookie that gets sent with a 'Max-Age', but no 'expires' attribute, will be accepted for that session, but will not persist after the browser is shut down. So, if you were to do the persistent cookie simulation in your automated testing described above, you would get a false-positive, when running the tests using IE. :( Using a new clean profile, every time the browser is started, in automated testing is the best practice. Sometimes there is a good reason to be able to shut down the browser and restart it, using the same profile that includes any artifacts or changes that occurred before the browser was shut down. In WebDriver, it is possible to initialize a WebDriver browser session, with a specific profile. If the quit method can be called with a parameter, that allows you to choose not reap the profile, then it is possible to initialize the next WebDriver browser session, using the profile directory and artifacts from the previous session. Reported by automated.test.spider on 2011-06-29 18:06:51