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..6dae8797a0d5f0054d57e3adfa44326fdc9434c5 |
--- /dev/null |
+++ b/components/test/data/password_manager/tests.py |
@@ -0,0 +1,477 @@ |
+# -*- coding: utf-8 -*- |
+"""Automated tests for many websites""" |
+ |
+ |
+import sys |
+ |
+from environment import Environment |
+from website import Website |
+ |
+ |
+# Working tests. |
+def WorkingTests(environment): |
vabr (Chromium)
2014/05/16 09:36:00
Since you specify "disabled" in AddWebsite(), you
rchtara
2014/05/20 08:24:47
Done.
|
+ |
+ |
+ class Amazon(Website): |
vabr (Chromium)
2014/05/16 09:36:00
Please extract the class definitions out of the fu
rchtara
2014/05/20 08:24:47
Done.
|
+ |
+ 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") |
+ |
+ environment.AddWebsite( |
+ Amazon( |
+ "amazon", |
+ "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"), |
+ disabled=True) |
+ |
+ |
+ class Espn(Website): |
+ |
+ 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") |
+ |
+ environment.AddWebsite( |
+ Espn( |
vabr (Chromium)
2014/05/16 09:36:00
nit: This line-break seems unnecessary.
rchtara
2014/05/20 08:24:47
Done.
|
+ "espn", |
+ "https://r.espn.go.com/members/v3_1/login?language=en®istrationFor" |
+ "mId=espn&affiliateName=espn&forwardUrl=&appRedirect=http%3A%2F%2F" |
+ "espn.go.com%2F&parentLocation=http%3A%2F%2Fespn.go.com%2F")) |
+ |
+ |
+ class Facebook(Website): |
+ |
+ 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']") |
+ |
+ environment.AddWebsite( |
+ Facebook("facebook", "https://www.facebook.com")) |
+ |
vabr (Chromium)
2014/05/16 09:36:00
nit: Keep in mind the style guide requires 2 blank
rchtara
2014/05/20 08:24:47
Done.
|
+ class Google(Website): |
+ |
+ 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.WaitUntilDisplayed(".gb_V.gbii") |
+ self.Click(".gb_V.gbii") |
+ self.WaitUntilDisplayed("#gb_71") |
+ self.Click("#gb_71") |
+ |
+ environment.AddWebsite( |
+ Google( |
+ "google", |
+ "https://accounts.google.com/ServiceLogin?sacu=1&continue=")) |
+ |
+ class Mailru(Website): |
+ |
+ 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") |
+ |
+ environment.AddWebsite(Mailru("mailru", "https://mail.ru")) |
+ |
+ class Nytimes(Website): |
+ |
+ 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") |
+ |
+ environment.AddWebsite( |
+ Nytimes("nytimes", "https://myaccount.nytimes.com/auth/login")) |
+ |
+ # website detected unsual activity |
+ class Pinterest(Website): |
+ |
+ 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/") |
+ |
+ environment.AddWebsite( |
+ Pinterest("pinterest", "https://www.pinterest.com/login/")) |
+ |
+ class Reddit(Website): |
+ |
+ 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") |
+ |
+ environment.AddWebsite( |
+ Reddit("reddit", "http://www.reddit.com", username_not_auto=True)) |
+ |
+ class Tumblr(Website): |
+ |
+ 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") |
+ |
+ environment.AddWebsite( |
+ Tumblr("tumblr", "https://www.tumblr.com/login", |
+ username_not_auto=True)) |
+ |
+ class Wikipedia(Website): |
+ |
+ 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") |
+ |
+ environment.AddWebsite( |
+ Wikipedia( |
+ "wikipedia", |
+ "https://en.wikipedia.org/w/index.php?title=Special:UserLogin", |
+ username_not_auto=True)) |
+ |
+ class Yandex(Website): |
+ |
+ 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") |
+ |
+ environment.AddWebsite(Yandex("yandex", "https://mail.yandex.com")) |
+ |
+ |
+# Disabled tests. |
+def DisabledTests(environment): |
+ |
+ |
+ class Ask(Website): |
+ |
+ 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") |
+ |
+ environment.AddWebsite(Ask("ask", "http://www.ask.com/answers/" |
+ "browse?qsrc=321&q=&o=0&l=dir#")) |
vabr (Chromium)
2014/05/16 09:36:00
nit: indenting is off
rchtara
2014/05/20 08:24:47
Done.
|
+ # crbug.com/368690 |
+ class Cnn(Website): |
+ |
+ 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") |
+ |
+ environment.AddWebsite(Cnn("cnn", "http://www.cnn.com"), disabled=True) |
+ |
+ # crbug.com/368690 |
+ class Ebay(Website): |
+ |
+ 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") |
+ |
+ environment.AddWebsite( |
+ Ebay("ebay", "https://signin.ebay.com/"), disabled=True) |
+ |
+ # crbug.com/367768 |
+ class Live(Website): |
+ |
+ 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") |
+ |
+ environment.AddWebsite( |
+ Live("live", "https://www.live.com", username_not_auto=True), |
+ disabled=True) |
+ |
+ # crbug.com/368690 |
+ class One63(Website): |
+ |
+ 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") |
+ |
+ environment.AddWebsite( |
+ One63("163", "http://www.163.com"), disabled=True) |
+ |
+ # crbug.com/368690 |
+ class Vube(Website): |
+ |
+ 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()']") |
+ |
+ environment.AddWebsite(Vube("vube", "https://vube.com"), disabled=True) |
+ |
+ |
+ # Tests that can cause a crash (the cause of the crash is not related to the |
vabr (Chromium)
2014/05/16 09:36:00
Are you really sure that the crash is not related
rchtara
2014/05/20 08:24:47
chrome crashes when click on sign out.
So it could
vabr (Chromium)
2014/05/20 14:47:25
So do you or do you not think it's related to the
rchtara
2014/05/22 08:44:38
Done.
|
+ # password manager). |
+ |
+ |
+ class Baidu(Website): |
+ |
+ 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") |
+ |
+ environment.AddWebsite( |
+ Baidu("baidu", "http://www.baidu.com/"), disabled=True) |
+ |
+ class Linkedin(Website): |
+ |
+ 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") |
+ |
+ environment.AddWebsite( |
+ Linkedin("linkedin", "https://www.linkedin.com"), disabled=True) |
+ |
+ class Yahoo(Website): |
+ |
+ 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") |
+ |
+ environment.AddWebsite( |
+ Yahoo("yahoo", "https://login.yahoo.com", username_not_auto=True), |
+ disabled=True) |
+ |
+ |
+# Tests setup. |
+if __name__ == "__main__": |
+ |
+ args = sys.argv[1:] |
+ if "--help" in args: |
vabr (Chromium)
2014/05/16 09:36:00
Please use argparse instead of handling the argume
vabr (Chromium)
2014/05/16 09:36:00
Also, in general, help should be printed if the ar
rchtara
2014/05/20 08:24:47
Done.
rchtara
2014/05/20 08:24:47
Done.
|
+ print "Password Manager automated tests help." |
vabr (Chromium)
2014/05/16 09:36:00
nit: Consider using multi-line strings """...""" i
rchtara
2014/05/20 08:24:47
Done.
|
+ print "Usage: python tests.py --chrome-path path --chromedriver-path path" |
+ print ("--profile-path path [--passwords-path path] [--all] [--help] " |
+ "[--log]") |
+ print ("[--log-file path] [test] ... .") |
+ print "--chrome-path : Set the chrome path (required)." |
+ print "--chromedriver-path : Set the chromedriver path (required)." |
+ print "--profile-path : Set the test profile path (required)." |
+ print ("You just need to choose a temporary empty folder. If the folder is " |
+ "not empty ") |
+ print "all its content is going to be removed." |
+ print "--passwords-path : Set the usernames/passwords path (optinal)" |
+ print "Default behavior : Run only working tests." |
+ print "--all : Run all tests." |
+ print "--log : Show log on the screen." |
+ print "--log-file : Write the log in a file." |
+ print "--help : Show help." |
+ print "test ... : Tests to be run." |
+ else: |
+ chrome_path = "" |
+ if "--chrome-path" not in args: |
+ sys.exit("Error: You have to specify the chrome path via --chrome-path") |
+ else: |
+ index = args.index("--chrome-path") |
+ chrome_path = args[index + 1] |
+ del args[index + 1] |
+ del args[index] |
+ |
+ chromedriver_path = "" |
+ if "--chromedriver-path" not in args: |
+ sys.exit("Error: You have to specify the chromedriver path via " |
+ "--chromedriver-path") |
+ else: |
+ index = args.index("--chromedriver-path") |
+ chromedriver_path = args[index + 1] |
+ del args[index + 1] |
+ del args[index] |
+ |
+ profile_path = "" |
+ if "--profile-path" not in args: |
+ sys.exit("Error: You have to specify the test profile path via " |
+ "--profile-path") |
+ else: |
+ index = args.index("--profile-path") |
+ profile_path = args[index + 1] |
+ del args[index + 1] |
+ del args[index] |
+ |
+ passwords_path = None |
+ if "--passwords-path" in args: |
+ index = args.index("--passwords-path") |
+ passwords_path = args[index + 1] |
+ del args[index + 1] |
+ del args[index] |
+ |
+ log_to_screen = False |
+ log_file = None |
+ if "--log" in args: |
+ index = args.index("--log") |
+ del args[index] |
+ log_to_screen = True |
+ if "--log-file" in args: |
+ index = args.index("--log-file") |
+ log_file = args[index + 1] |
+ del args[index + 1] |
+ del args[index] |
+ |
+ |
+ testing_environment = Environment(chrome_path, chromedriver_path, |
+ profile_path, passwords_path, |
+ log_to_screen, log_file) |
+ WorkingTests(testing_environment) |
+ DisabledTests(testing_environment) |
+ |
+ if len(args) == 0: |
+ testing_environment.WorkingTests() |
+ elif "--all" in args: |
+ testing_environment.AllTests() |
+ else: |
+ testing_environment.Test(args) |
+ |
+ testing_environment.Quit() |