summaryrefslogtreecommitdiffstats
path: root/components/test/data/password_manager/tests.py
diff options
context:
space:
mode:
Diffstat (limited to 'components/test/data/password_manager/tests.py')
-rw-r--r--components/test/data/password_manager/tests.py515
1 files changed, 515 insertions, 0 deletions
diff --git a/components/test/data/password_manager/tests.py b/components/test/data/password_manager/tests.py
new file mode 100644
index 0000000..af9f44e
--- /dev/null
+++ b/components/test/data/password_manager/tests.py
@@ -0,0 +1,515 @@
+# Copyright 2014 The Chromium Authors. All rights reserved.
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+# -*- 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.ClickIfClickable(".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")
+
+
+# http://crbug.com/368690
+class Cnn(WebsiteTest):
+
+ def Login(self):
+ self.GoTo("http://www.cnn.com")
+ self.Wait(5)
+ while not self.IsDisplayed(".cnnOvrlyBtn.cnnBtnLogIn"):
+ self.ClickIfClickable("#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")
+
+
+# http://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.ClickIfClickable("#submitBtn")
+ self.Wait(1)
+
+ def Logout(self):
+ self.WaitUntilDisplayed("#signin .small")
+ self.Click("#signin .small")
+
+
+# http://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")
+
+
+# http://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")
+
+
+# http://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.ClickIfClickable("[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.
+
+
+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)
+
+ # http://crbug.com/368690
+ environment.AddWebsiteTest(Cnn("cnn"), disabled=True)
+
+ # http://crbug.com/368690
+ environment.AddWebsiteTest(Ebay("ebay"), disabled=True)
+
+ # Iframe, password saved but not autofileld.
+ environment.AddWebsiteTest(Espn("espn"), disabled=True)
+
+ # http://crbug.com/367768
+ environment.AddWebsiteTest(Live("live", username_not_auto=True),
+ disabled=True)
+
+ # http://crbug.com/368690
+ environment.AddWebsiteTest(One63("163"), disabled=True)
+
+ # http://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,
+ environment_passwords_path, enable_automatic_password_saving,
+ environment_numeric_level, log_to_console, environment_log_file,
+ all_tests, tests):
+
+ """Runs the the tests
+
+ Args:
+ chrome_path: The chrome binary file.
+ chromedriver_path: The chromedriver binary file.
+ profile_path: The chrome testing profile folder.
+ environment_passwords_path: The usernames and passwords file.
+ enable_automatic_password_saving: If True, the passwords are going to be
+ saved without showing the prompt.
+ environment_numeric_level: The log verbosity.
+ log_to_console: If True, the debug logs will be shown on the console.
+ environment_log_file: The file where to store the log. If it's empty, the
+ log is not stored.
+ all_tests: If True, all the tests are going to be ran.
+ tests: A list of the names of the WebsiteTests that are going to be tested.
+
+ Raises:
+ Exception: An exception is raised if the one of the tests fails.
+ """
+
+ environment = Environment(chrome_path, chromedriver_path, profile_path,
+ environment_passwords_path,
+ enable_automatic_password_saving,
+ environment_numeric_level,
+ log_to_console,
+ environment_log_file)
+
+ # Test which care about the save-password prompt need the prompt
+ # to be shown. Automatic password saving results in no prompt.
+ run_prompt_tests = not enable_automatic_password_saving
+
+ Tests(environment)
+
+ if all_tests:
+ environment.AllTests(run_prompt_tests)
+ elif tests:
+ environment.Test(tests, run_prompt_tests)
+ else:
+ environment.WorkingTests(run_prompt_tests)
+
+ 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 "
+ "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 (required).", nargs=1,
+ required=True)
+ 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 = 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 stored in the the way we expected.
+ 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)