Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(35)

Side by Side Diff: components/test/data/password_manager/environment.py

Issue 472823002: The password manager python tests now logout from websites by cleaning the cookies. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | components/test/data/password_manager/tests.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 # Copyright 2014 The Chromium Authors. All rights reserved. 1 # Copyright 2014 The Chromium Authors. All rights reserved.
2 # Use of this source code is governed by a BSD-style license that can be 2 # Use of this source code is governed by a BSD-style license that can be
3 # found in the LICENSE file. 3 # found in the LICENSE file.
4 4
5 """The testing Environment class.""" 5 """The testing Environment class."""
6 6
7 import logging 7 import logging
8 import shutil 8 import shutil
9 import sys 9 import sys
10 import time 10 import time
(...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after
165 else: 165 else:
166 self.working_tests.append(websitetest.name) 166 self.working_tests.append(websitetest.name)
167 167
168 def RemoveAllPasswords(self): 168 def RemoveAllPasswords(self):
169 """Removes all the stored passwords.""" 169 """Removes all the stored passwords."""
170 logging.info("\nRemoveAllPasswords\n") 170 logging.info("\nRemoveAllPasswords\n")
171 self.driver.get("chrome://settings/passwords") 171 self.driver.get("chrome://settings/passwords")
172 self.driver.switch_to_frame("settings") 172 self.driver.switch_to_frame("settings")
173 while True: 173 while True:
174 try: 174 try:
175 self.driver.execute_script("document.querySelector('" 175 self.driver.execute_script(
176 "#saved-passwords-list .row-delete-button').click()") 176 "document.querySelector('#saved-passwords-list .row-delete-button')"
177 ".click()")
177 time.sleep(1) 178 time.sleep(1)
178 except NoSuchElementException: 179 except NoSuchElementException:
179 break 180 break
180 except WebDriverException: 181 except WebDriverException:
181 break 182 break
182 183
184 def ClearAllCookies(self):
185 """Removes all the cookies."""
186 logging.info("\nClearAllCookies\n")
187 self.driver.get("chrome://settings/clearBrowserData")
188 self.driver.switch_to_frame("settings")
189 self.driver.execute_script(
190 "var checkboxes = document.querySelectorAll("
191 " '#clear-data-checkboxes [type=\\\'checkbox\\\']');"
192 "for (var i in checkboxes)"
193 " checkboxes[i].checked = false;"
194 "document.querySelector('#delete-cookies-checkbox').checked = true;"
195 "document.querySelector('#clear-browser-data-commit').click();")
196 time.sleep(2)
197
183 def OpenTabAndGoToInternals(self, url): 198 def OpenTabAndGoToInternals(self, url):
184 """If there is no |self.website_window|, opens a new tab and navigates to 199 """If there is no |self.website_window|, opens a new tab and navigates to
185 |url| in the new tab. Navigates to the passwords internals page in the 200 |url| in the new tab. Navigates to the passwords internals page in the
186 first tab. Raises an exception otherwise. 201 first tab. Raises an exception otherwise.
187 202
188 Args: 203 Args:
189 url: Url to go to in the new tab. 204 url: Url to go to in the new tab.
190 205
191 Raises: 206 Raises:
192 Exception: An exception is raised if |self.website_window| already 207 Exception: An exception is raised if |self.website_window| already
(...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after
387 except Exception: 402 except Exception:
388 successful = False 403 successful = False
389 error = traceback.format_exc() 404 error = traceback.format_exc()
390 self.tests_results.append(TestResult(websitetest.name, "prompt", 405 self.tests_results.append(TestResult(websitetest.name, "prompt",
391 successful, escape(error))) 406 successful, escape(error)))
392 407
393 def Quit(self): 408 def Quit(self):
394 """Closes the tests.""" 409 """Closes the tests."""
395 # Close the webdriver. 410 # Close the webdriver.
396 self.driver.quit() 411 self.driver.quit()
OLDNEW
« no previous file with comments | « no previous file | components/test/data/password_manager/tests.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698