| 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..61b19fa389fd6f0e8f8e1cfcd7974d399049d1bc
|
| --- /dev/null
|
| +++ b/components/test/data/password_manager/tests.py
|
| @@ -0,0 +1,454 @@
|
| +# -*- coding: utf-8 -*-
|
| +"""Automated tests for many websites"""
|
| +
|
| +
|
| +import sys
|
| +
|
| +from environment import Environment
|
| +from website import Website
|
| +
|
| +
|
| +# Working tests.
|
| +def WorkingTests(environment):
|
| +
|
| + class Amazon(Website):
|
| +
|
| + 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.FillUsername("[name='email']")
|
| + self.FillPassword("[name='password']")
|
| + self.Submit("[name='password']")
|
| +
|
| + def Logout(self):
|
| + self.Wait(2)
|
| + self.WaitUntilDisplayed("#nav-signin-title")
|
| + self.Hover("#nav-signin-title")
|
| + self.WaitUntilDisplayed("#nav-item-signout")
|
| + 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"))
|
| +
|
| + 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.FillUsername("[name='username']")
|
| + self.FillPassword("[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#"))
|
| +
|
| + 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.FillUsername("#username")
|
| + self.FillPassword("#password")
|
| + while self.IsDisplayed("#password"):
|
| + self.ClickIfAvailable("#submitBtn")
|
| + self.Wait(1)
|
| +
|
| + def Logout(self):
|
| + self.WaitUntilDisplayed("#signin .small")
|
| + self.Click("#signin .small")
|
| +
|
| + environment.AddWebsite(
|
| + Espn(
|
| + "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.FillUsername("[name='email']")
|
| + self.FillPassword("[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"))
|
| +
|
| + class Google(Website):
|
| +
|
| + def Login(self):
|
| + self.GoTo("https://accounts.google.com/ServiceLogin?sacu=1&continue=")
|
| + self.FillUsername("#Email")
|
| + self.FillPassword("#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.FillUsername("#mailbox__login")
|
| + self.FillPassword("#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.FillUsername("#userid")
|
| + self.FillPassword("#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.FillUsername("[name='username_or_email']")
|
| + self.FillPassword("[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.FillUsername("#user_login")
|
| + self.FillPassword("#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.FillUsername("#signup_email")
|
| + self.FillPassword("#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.FillUsername("#wpName1")
|
| + self.FillPassword("#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.FillUsername("#b-mail-domik-username11")
|
| + self.FillPassword("#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.ClickIfAvailable(".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"))
|
| +
|
| +
|
| +# Failing tests.
|
| +def FailingTests(environment):
|
| +
|
| + # 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.ClickIfAvailable("#hdr-auth .no-border.no-pad-right a")
|
| + self.Wait(1)
|
| +
|
| + self.Click(".cnnOvrlyBtn.cnnBtnLogIn")
|
| + self.FillUsername("#cnnOverlayEmail1l")
|
| + self.FillPassword("#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"), failing=True)
|
| +
|
| + # crbug.com/368690
|
| + class Ebay(Website):
|
| +
|
| + def Login(self):
|
| + self.GoTo("https://signin.ebay.com/")
|
| + self.FillUsername("[name='userid']")
|
| + self.FillPassword("[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/"), failing=True)
|
| +
|
| + # crbug.com/367768
|
| + class Live(Website):
|
| +
|
| + def Login(self):
|
| + self.GoTo("https://www.live.com")
|
| + self.FillUsername("[name='login']")
|
| + self.FillPassword("[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),
|
| + failing=True)
|
| +
|
| + # crbug.com/368690
|
| + class One63(Website):
|
| +
|
| + def Login(self):
|
| + self.GoTo("http://www.163.com")
|
| + self.Hover("#js_N_navHighlight")
|
| + self.WaitUntilDisplayed("#js_loginframe_username")
|
| + self.FillUsername("#js_loginframe_username")
|
| + self.FillPassword(".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"), failing=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.FillUsername("[ng-model='login.user']")
|
| + self.FillPassword("[ng-model='login.pass']")
|
| + while (self.IsDisplayed("[ng-model='login.pass']")
|
| + and not self.IsDisplayed(".prompt.alert")):
|
| + self.ClickIfAvailable("[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"), failing=True)
|
| +
|
| + # Tests that can cause a crash (the cause of the crash is not related to the
|
| + # password manager).
|
| + class Baidu(Website):
|
| +
|
| + def Login(self):
|
| + self.GoTo("http://www.baidu.com/")
|
| + self.Click("[name='tj_login']")
|
| + self.WaitUntilDisplayed("[name='userName']")
|
| + self.FillUsername("[name='userName']")
|
| + self.FillPassword("[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/"), failing=True)
|
| +
|
| + class Linkedin(Website):
|
| +
|
| + def Login(self):
|
| + self.GoTo("https://www.linkedin.com")
|
| + self.FillUsername("#session_key-login")
|
| + self.FillPassword("#session_password-login")
|
| + self.Submit("#session_password-login")
|
| +
|
| + def Logout(self):
|
| + self.WaitUntilDisplayed(".account-toggle")
|
| + self.Hover(".account-toggle")
|
| + self.WaitUntilDisplayed(".account-settings .act-set-action")
|
| + self.Click(".account-settings .act-set-action")
|
| +
|
| + environment.AddWebsite(
|
| + Linkedin("linkedin", "https://www.linkedin.com"), failing=True)
|
| +
|
| + class Yahoo(Website):
|
| +
|
| + def Login(self):
|
| + self.GoTo("https://login.yahoo.com")
|
| + self.FillUsername("#username")
|
| + self.FillPassword("#passwd")
|
| + self.Submit("#passwd")
|
| +
|
| + def Logout(self):
|
| + self.WaitUntilDisplayed(".tab.tab-user>.mod.view_default")
|
| + self.Hover(".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),
|
| + failing=True)
|
| +
|
| +
|
| +# Tests setup.
|
| +if __name__ == "__main__":
|
| +
|
| + args = sys.argv[1:]
|
| + if "--help" in args:
|
| + print "Password Manager automated tests help."
|
| + print "Usage: python tests.py --chrome-path path --chromedriver-path path"
|
| + print ("--profile-path path [--passwords-path path] [--all] [--help] "
|
| + "[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 "--help : Show help."
|
| + print "--all : Run all tests."
|
| + 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]
|
| +
|
| + testing_environment = Environment(chrome_path, chromedriver_path,
|
| + profile_path, passwords_path)
|
| + WorkingTests(testing_environment)
|
| + FailingTests(testing_environment)
|
| +
|
| + if len(args) == 0:
|
| + testing_environment.WorkingTests()
|
| + elif "--all" in args:
|
| + testing_environment.AllTests()
|
| + else:
|
| + testing_environment.Test(args)
|
| +
|
| + testing_environment.Quit()
|
|
|