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

Unified Diff: components/test/data/password_manager/environment.py

Issue 273523004: Password Manager testing automation (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 7 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 side-by-side diff with in-line comments
Download patch
Index: components/test/data/password_manager/environment.py
diff --git a/components/test/data/password_manager/environment.py b/components/test/data/password_manager/environment.py
new file mode 100644
index 0000000000000000000000000000000000000000..2f287fc2cc681e0dbd92a4c78626276f99da837d
--- /dev/null
+++ b/components/test/data/password_manager/environment.py
@@ -0,0 +1,104 @@
+import time
+from selenium import webdriver
+from selenium.webdriver.chrome.options import Options
+import xml.etree.ElementTree as ET
+
+from website import Website
+
+
+class Environment:
+
+ def __init__(self, passwords_file = ""):
+ options = Options()
+ """Use random empty folder for profile, otherwise chromedriver is going to
+ create it's own where saving passwords is disabled.
+ """
+ options.add_argument("enable-automatic-password-saving")
+ #chrome path
+ options.binary_location = (
+ "/usr/local/google/home/rchtara/chrome/src/out/Debug/chrome")
+ #new profile path
+ options.add_argument("user-data-dir=/tmp/ChromePasswordManagerTestvvvvvv")
+ #chromedriver path
+ self.driver = webdriver.Chrome(
+ "/usr/local/google/home/rchtara/chrome/src/out/Debug/chromedriver", 0,
+ options)
+ self.internals_window = self.driver.current_window_handle
+ self.websitewindow = None
+ self.websites = []
+
+ self.passwords_tree = None
+ if passwords_file != "":
+ self.passwords_tree = ET.parse(passwords_file).getroot()
+
+ def AddWebsite(self,
+ name,
+ username = None,
+ password = None,
+ username_not_auto=False):
+ website = (
+ Website(
+ name, username, password, self.driver, self, username_not_auto))
+ self.websites.append(website)
+ return website
+
+ def RemoveAllPasswords(self):
+ print "RemoveAllPasswords"
+ self.driver.get("chrome://settings/passwords")
+ self.driver.switch_to_frame("settings")
+
+ for website in self.websites:
+ urls, _ = self.GetPasswordsAndButtons()
+ website.RemoveAllPasswords(urls)
+
+ def GetPasswordsAndButtons(self):
+ arr = self.driver.find_elements_by_css_selector(
+ "#saved-passwords-list .deletable-item")
+ urls = []
+ remove_buttons = []
+ for entry in arr:
+ urls.append(entry.find_element_by_class_name("url").text)
+ remove_buttons.append(
+ entry.find_element_by_class_name("row-delete-button"))
+ return (urls, remove_buttons)
+
+ def NewWindow(self):
+ if self.websitewindow == None:
+ self.driver.get("https://google.com")
+
+ """It's not possible to open a new tab to chrome:// urls directly,
+ this why we go to google.com website then we go to chrome://
+ sometime chromedriver doesn't detect that www.google.com is loaded
+ and the script just stops, this is why you should redo the
+ tests again.
+ """
+
+ a = self.driver.execute_script(
+ "var d=document; var "
+ "a=d.createElement('a');a.target='_blank';a.href=arguments[0];"
+ "a.innerHTML='.';d.body.appendChild(a);"
+ " return a;",
+ "https://google.com")
+ a.click()
+ time.sleep(1)
+
+ self.websitewindow = self.driver.window_handles[-1]
+
+ self.driver.switch_to_window(self.websitewindow)
+
+ def AllTests(self):
+ self.RemoveAllPasswords()
+ self.NewWindow()
+ for website in self.websites:
+ website.WrongLoginTest()
+ website.SucessfulLoginTest()
+ website.SucessfulLoginWithAutofilledPasswordTest()
+
+ self.RemoveAllPasswords()
+ for website in self.websites:
+ website.SucessfulLoginAfterDeletionTest()
+
+ def Quit(self):
+ self.driver.quit()
+
+

Powered by Google App Engine
This is Rietveld 408576698