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

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

Issue 273523004: Password Manager testing automation (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: renaming 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/tests.py
diff --git a/components/test/data/password_manager/tests.py b/components/test/data/password_manager/tests.py
new file mode 100644
index 0000000000000000000000000000000000000000..79f4aa02e7f283536b2953dea7d8d9619e5d8ddd
--- /dev/null
+++ b/components/test/data/password_manager/tests.py
@@ -0,0 +1,489 @@
+# -*- coding: utf-8 -*-
+"""Automated tests for many websites"""
+
+import argparse
+import logging
+
+from environment import Environment
+from websitetest import WebsiteTest
+
+
+class Facebook(WebsiteTest):
+
+ def Login(self):
+ self.GoTo("https://www.facebook.com")
+ self.FillUsernameInto("[name='email']")
+ self.FillPasswordInto("[name='pass']")
+ self.Submit("[name='pass']")
+
+ def Logout(self):
+ self.WaitUntilDisplayed("#userNavigationLabel")
+ self.Click("#userNavigationLabel")
+ self.WaitUntilDisplayed("#logout_form [type='submit']")
+ self.Click("#logout_form [type='submit']")
+
+
+class Google(WebsiteTest):
+
+ def Login(self):
+ self.GoTo("https://accounts.google.com/ServiceLogin?sacu=1&continue=")
+ self.FillUsernameInto("#Email")
+ self.FillPasswordInto("#Passwd")
+ self.Submit("#Passwd")
+
+ def Logout(self):
+ self.GoTo("https://accounts.google.com/Logout")
+
+
+class Linkedin(WebsiteTest):
+
+ def Login(self):
+ self.GoTo("https://www.linkedin.com")
+ self.FillUsernameInto("#session_key-login")
+ self.FillPasswordInto("#session_password-login")
+ self.Submit("#session_password-login")
+
+ def Logout(self):
+ self.WaitUntilDisplayed(".account-toggle")
+ self.HoverOver(".account-toggle")
+ self.WaitUntilDisplayed(".account-settings .act-set-action")
+ self.Click(".account-settings .act-set-action")
+
+
+class Mailru(WebsiteTest):
+
+ def Login(self):
+ self.GoTo("https://mail.ru")
+ self.FillUsernameInto("#mailbox__login")
+ self.FillPasswordInto("#mailbox__password")
+ self.Submit("#mailbox__password")
+
+ def Logout(self):
+ self.Click("#PH_logoutLink")
+
+
+class Nytimes(WebsiteTest):
+
+ def Login(self):
+ self.GoTo("https://myaccount.nytimes.com/auth/login")
+ self.FillUsernameInto("#userid")
+ self.FillPasswordInto("#password")
+ self.Submit("#password")
+
+ def Logout(self):
+ self.GoTo("https://myaccount.nytimes.com/gst/signout")
+
+
+class Pinterest(WebsiteTest):
+
+ def Login(self):
+ self.GoTo("https://www.pinterest.com/login/")
+ self.FillUsernameInto("[name='username_or_email']")
+ self.FillPasswordInto("[name='password']")
+ self.Submit("[name='password']")
+
+ def Logout(self):
+ self.GoTo("https://www.pinterest.com/logout/")
+
+
+class Reddit(WebsiteTest):
+
+ def Login(self):
+ self.GoTo("http://www.reddit.com")
+ self.Click(".user .login-required")
+ self.FillUsernameInto("#user_login")
+ self.FillPasswordInto("#passwd_login")
+ self.Wait(2)
+ self.Submit("#passwd_login")
+
+ def Logout(self):
+ self.Click("form[action='http://www.reddit.com/logout'] a")
+
+
+class Tumblr(WebsiteTest):
+
+ def Login(self):
+ self.GoTo("https://www.tumblr.com/login")
+ self.FillUsernameInto("#signup_email")
+ self.FillPasswordInto("#signup_password")
+ self.Submit("#signup_password")
+
+ def Logout(self):
+ self.GoTo("https://www.tumblr.com/logout")
+
+
+class Wikipedia(WebsiteTest):
+
+ def Login(self):
+ self.GoTo("https://en.wikipedia.org/w/index.php?title=Special:UserLogin")
+ self.FillUsernameInto("#wpName1")
+ self.FillPasswordInto("#wpPassword1")
+ self.Submit("#wpPassword1")
+
+ def Logout(self):
+ self.GoTo("https://en.wikipedia.org/w/index.php?title=Special:UserLogout")
+
+
+class Yandex(WebsiteTest):
+
+ def Login(self):
+ self.GoTo("https://mail.yandex.com")
+ self.FillUsernameInto("#b-mail-domik-username11")
+ self.FillPasswordInto("#b-mail-domik-password11")
+ self.Click(".b-mail-button__button")
+
+ def Logout(self):
+ while not self.IsDisplayed(".b-mail-dropdown__item__content"
+ u".Выход.daria-action"):
+ self.ClickIfVisible(".header-user-pic.b-mail-dropdown__handle")
+ self.Wait(1)
+ self.Click(u".b-mail-dropdown__item__content.Выход.daria-action")
+
+
+# Disabled tests.
+
+
+# Bug not reproducible without test.
+class Amazon(WebsiteTest):
+
+ def Login(self):
+ self.GoTo(
+ "https://www.amazon.com/ap/signin?openid.assoc_handle=usflex"
+ "&openid.mode=checkid_setup&openid.ns=http%3A%2F%2Fspecs.openid.net"
+ "%2Fauth%2F2.0")
+ self.FillUsernameInto("[name='email']")
+ self.FillPasswordInto("[name='password']")
+ self.Submit("[name='password']")
+
+ def Logout(self):
+ while not self.IsDisplayed("#nav-item-signout"):
+ self.Wait(1)
+ self.HoverOver("#nav-signin-title")
+ self.Click("#nav-item-signout")
+
+
+# Password not saved.
+class Ask(WebsiteTest):
+
+ def Login(self):
+ self.GoTo("http://www.ask.com/answers/browse?qsrc=321&q=&o=0&l=dir#")
+ while not self.IsDisplayed("[name='username']"):
+ self.Click("#a16CnbSignInText")
+ self.Wait(1)
+ self.FillUsernameInto("[name='username']")
+ self.FillPasswordInto("[name='password']")
+ self.Click(".signin_show.signin_submit")
+
+ def Logout(self):
+ self.WaitUntilDisplayed("#a16CnbSignInText")
+ self.Click("#a16CnbSignInText")
+
+
+# Password not saved.
+class Baidu(WebsiteTest):
+
+ def Login(self):
+ self.GoTo("http://www.baidu.com/")
+ self.Click("[name='tj_login']")
+ self.WaitUntilDisplayed("[name='userName']")
+ self.FillUsernameInto("[name='userName']")
+ self.FillPasswordInto("[name='password']")
+ self.Submit("[name='password']")
+
+ def Logout(self):
+ self.Wait(1)
+ self.GoTo("https://passport.baidu.com/?logout&u=http://www.baidu.com")
+
+
+# crbug.com/368690
vabr (Chromium) 2014/05/20 14:47:25 nit: If you prefix the URL with "http://", the lin
rchtara 2014/05/22 08:44:38 Done.
+class Cnn(WebsiteTest):
+
+ def Login(self):
+ self.GoTo("http://www.cnn.com")
+ self.Wait(5)
+ while not self.IsDisplayed(".cnnOvrlyBtn.cnnBtnLogIn"):
+ self.ClickIfVisible("#hdr-auth .no-border.no-pad-right a")
+ self.Wait(1)
+
+ self.Click(".cnnOvrlyBtn.cnnBtnLogIn")
+ self.FillUsernameInto("#cnnOverlayEmail1l")
+ self.FillPasswordInto("#cnnOverlayPwd")
+ self.Click(".cnnOvrlyBtn.cnnBtnLogIn")
+ self.Click(".cnnOvrlyBtn.cnnBtnLogIn")
+ self.Wait(5)
+
+ def Logout(self):
+ self.Wait(4)
+ self.Click("#hdr-auth .no-border.no-pad-right")
+
+
+# crbug.com/368690
+class Ebay(WebsiteTest):
+
+ def Login(self):
+ self.GoTo("https://signin.ebay.com/")
+ self.FillUsernameInto("[name='userid']")
+ self.FillPasswordInto("[name='pass']")
+ self.Submit("[name='pass']")
+
+ def Logout(self):
+ self.WaitUntilDisplayed("#gh-ug")
+ self.Click("#gh-ug")
+ self.WaitUntilDisplayed("#gh-uo")
+ self.Click("#gh-uo")
+
+
+# Iframe, password saved but not autofileld.
+class Espn(WebsiteTest):
+
+ def Login(self):
+ self.GoTo("http://espn.go.com/")
+ while not self.IsDisplayed("#cboxLoadedContent iframe"):
+ self.Click("#signin .cbOverlay")
+ self.Wait(1)
+ frame = self.driver.find_element_by_css_selector("#cboxLoadedContent "
+ "iframe")
+ self.driver.switch_to_frame(frame)
+ self.WaitUntilDisplayed("#username")
+ self.FillUsernameInto("#username")
+ self.FillPasswordInto("#password")
+ while self.IsDisplayed("#password"):
+ self.ClickIfVisible("#submitBtn")
+ self.Wait(1)
+
+ def Logout(self):
+ self.WaitUntilDisplayed("#signin .small")
+ self.Click("#signin .small")
+
+
+# crbug.com/367768
+class Live(WebsiteTest):
+
+ def Login(self):
+ self.GoTo("https://www.live.com")
+ self.FillUsernameInto("[name='login']")
+ self.FillPasswordInto("[name='passwd']")
+ self.Submit("[name='passwd']")
+
+ def Logout(self):
+ self.WaitUntilDisplayed("#c_meun")
+ self.Click("#c_meun")
+ self.WaitUntilDisplayed("#c_signout")
+ self.Click("#c_signout")
+
+
+# crbug.com/368690
+class One63(WebsiteTest):
+
+ def Login(self):
+ self.GoTo("http://www.163.com")
+ self.HoverOver("#js_N_navHighlight")
+ self.WaitUntilDisplayed("#js_loginframe_username")
+ self.FillUsernameInto("#js_loginframe_username")
+ self.FillPasswordInto(".ntes-loginframe-label-ipt[type='password']")
+ self.Click(".ntes-loginframe-btn")
+
+ def Logout(self):
+ self.WaitUntilDisplayed("#js_N_navLogout")
+ self.Click("#js_N_navLogout")
+
+
+# crbug.com/368690
+class Vube(WebsiteTest):
+
+ def Login(self):
+ self.GoTo("https://vube.com")
+ self.Click("[vube-login='']")
+ self.WaitUntilDisplayed("[ng-model='login.user']")
+ self.FillUsernameInto("[ng-model='login.user']")
+ self.FillPasswordInto("[ng-model='login.pass']")
+ while (self.IsDisplayed("[ng-model='login.pass']")
+ and not self.IsDisplayed(".prompt.alert")):
+ self.ClickIfVisible("[ng-click='login()']")
+ self.Wait(1)
+
+ def Logout(self):
+ self.WaitUntilDisplayed("[ng-click='user.logout()']")
+ self.Click("[ng-click='user.logout()']")
+
+
+# Tests that can cause a crash (the cause of the crash is not related to the
+# password manager).
+
+
+class Yahoo(WebsiteTest):
+
+ def Login(self):
+ self.GoTo("https://login.yahoo.com")
+ self.FillUsernameInto("#username")
+ self.FillPasswordInto("#passwd")
+ self.Submit("#passwd")
+
+ def Logout(self):
+ self.WaitUntilDisplayed(".tab.tab-user>.mod.view_default")
+ self.HoverOver(".tab.tab-user>.mod.view_default")
+ self.WaitUntilDisplayed("[data-pos='4'] .lbl.y-link-1")
+ self.Click("[data-pos='4'] .lbl.y-link-1")
+
+
+def Tests(environment):
+
+
+ # Working tests.
+
+
+ environment.AddWebsiteTest(Facebook("facebook"))
+
+ environment.AddWebsiteTest(Google("google"))
+
+ environment.AddWebsiteTest(Linkedin("linkedin"))
+
+ environment.AddWebsiteTest(Mailru("mailru"))
+
+ environment.AddWebsiteTest(Nytimes("nytimes"))
+
+ environment.AddWebsiteTest(Pinterest("pinterest"))
+
+ environment.AddWebsiteTest(Reddit("reddit", username_not_auto=True))
+
+ environment.AddWebsiteTest(Tumblr("tumblr", username_not_auto=True))
+
+ environment.AddWebsiteTest(Wikipedia("wikipedia", username_not_auto=True))
+
+ environment.AddWebsiteTest(Yandex("yandex"))
+
+
+ # Disabled tests.
+
+
+ # Bug not reproducible without test.
+ environment.AddWebsiteTest(Amazon("amazon"), disabled=True)
+
+ # Password not saved.
+ environment.AddWebsiteTest(Ask("ask"), disabled=True)
+
+ # Password not saved.
+ environment.AddWebsiteTest(Baidu("baidu"), disabled=True)
+
+ # crbug.com/368690
+ environment.AddWebsiteTest(Cnn("cnn"), disabled=True)
+
+ # crbug.com/368690
+ environment.AddWebsiteTest(Ebay("ebay"), disabled=True)
+
+ # Iframe, password saved but not autofileld.
+ environment.AddWebsiteTest(Espn("espn"), disabled=True)
+
+ # crbug.com/367768
+ environment.AddWebsiteTest(Live("live", username_not_auto=True),
+ disabled=True)
+
+ # crbug.com/368690
+ environment.AddWebsiteTest(One63("163"), disabled=True)
+
+ # crbug.com/368690
+ environment.AddWebsiteTest(Vube("vube"), disabled=True)
+
+ # Tests that can cause a crash (the cause of the crash is not related to the
+ # password manager).
+ environment.AddWebsiteTest(Yahoo("yahoo", username_not_auto=True),
+ disabled=True)
+
+
+def RunTests(chrome_path, chromedriver_path, profile_path,
vabr (Chromium) 2014/05/20 14:47:25 Please add a documentation string for this functio
rchtara 2014/05/22 08:44:38 Done.
+ environment_passwords_path, enable_automatic_password_saving,
+ environment_numeric_level, log_screen, environment_log_file,
+ all_tests, tests):
+
+ environment = Environment(chrome_path, chromedriver_path, profile_path,
+ environment_passwords_path,
+ enable_automatic_password_saving,
+ environment_numeric_level,
+ log_screen,
+ environment_log_file)
+
+
+ Tests(environment)
+
+ if all_tests:
+ environment.AllTests(not enable_automatic_password_saving)
+ elif len(tests) == 0:
vabr (Chromium) 2014/05/20 14:47:25 "len(tests) == 0" -> "not tests" (search for "len(
rchtara 2014/05/22 08:44:38 Done.
+ environment.WorkingTests(not enable_automatic_password_saving)
+ else:
+ environment.Test(tests, not enable_automatic_password_saving)
+
+ environment.Quit()
+
+
+# Tests setup.
+if __name__ == "__main__":
+ parser = argparse.ArgumentParser(
+ description="Password Manager automated tests help.")
+
+ parser.add_argument(
+ "--chrome-path", action="store", dest="chrome_path",
+ help="Set the chrome path (required).", nargs=1, required=True)
+ parser.add_argument(
+ "--chromedriver-path", action="store", dest="chromedriver_path",
+ help="Set the chromedriver path (required).", nargs=1, required=True)
+ parser.add_argument(
+ "--profile-path", action="store", dest="profile_path",
+ help="""Set the profile path (required). You just need to choose a
vabr (Chromium) 2014/05/20 14:47:25 I suggest using single quotes (plus \ at the end o
rchtara 2014/05/22 08:44:38 Done.
+ temporary empty folder. If the folder is not empty all its content is
+ going to be removed.""", nargs=1, required=True)
+
+ parser.add_argument(
+ "--passwords-path", action="store", dest="passwords_path",
+ help="Set the usernames/passwords path (optional).", nargs=1)
+ parser.add_argument("--all", action="store_true", dest="all",
+ help="Run all tests.")
+ parser.add_argument("--log", action="store", nargs=1, dest="log_level",
+ help="Set log level.")
+
+ parser.add_argument("--log-screen", action="store_true", dest="log_screen",
+ help="Show log on the screen.")
+ parser.add_argument("--log-file", action="store", dest="log_file",
+ help="Write the log in a file.", nargs=1)
+ parser.add_argument("tests", help="Tests to be run.", nargs="*")
+
+ args = parser.parse_args()
+
+ passwords_path = None
+ if args.passwords_path:
+ passwords_path = args.passwords_path[0]
+
+ numeric_level = None
+ if args.log_level:
+ numeric_level = getattr(logging, args.log_level[0].upper(), None)
+ if not isinstance(numeric_level, int):
+ raise ValueError("Invalid log level: %s" % args.log_level[0])
+
+ log_file = None
+ if args.log_file:
+ log_file = args.log_file[0]
+
+ # Run the test without enable-automatic-password-saving to check whether or
+ # not the prompt is shown in the way we expected.
+ RunTests(args.chrome_path[0],
+ args.chromedriver_path[0],
+ args.profile_path[0],
+ passwords_path,
+ False,
+ numeric_level,
+ args.log_screen,
+ log_file,
+ args.all,
+ args.tests)
+
+ # Run the test with enable-automatic-password-saving to check whether or not
+ # the passwords is shown in the the way we expected.
vabr (Chromium) 2014/05/20 14:47:25 nit: Did you mean "stored" instead of "shown"?
rchtara 2014/05/22 08:44:38 Done.
+ RunTests(args.chrome_path[0],
+ args.chromedriver_path[0],
+ args.profile_path[0],
+ passwords_path,
+ True,
+ numeric_level,
+ args.log_screen,
+ log_file,
+ args.all,
+ args.tests)

Powered by Google App Engine
This is Rietveld 408576698