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

Side by Side Diff: components/test/data/password_manager/automated_tests/tests.py

Issue 1012863006: [Password manager Python tests] Remove the option to disable tests (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 9 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 unified diff | Download patch
« no previous file with comments | « components/test/data/password_manager/automated_tests/environment.py ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 # -*- coding: utf-8 -*- 1 # -*- coding: utf-8 -*-
2 # Copyright 2014 The Chromium Authors. All rights reserved. 2 # Copyright 2014 The Chromium Authors. All rights reserved.
3 # Use of this source code is governed by a BSD-style license that can be 3 # Use of this source code is governed by a BSD-style license that can be
4 # found in the LICENSE file. 4 # found in the LICENSE file.
5 5
6 """Automated tests for many websites""" 6 """Automated tests for many websites"""
7 7
8 import argparse 8 import argparse
9 import logging 9 import logging
10 10
11 from environment import Environment 11 from environment import Environment
12 from websitetest import WebsiteTest 12 from websitetest import WebsiteTest
13 13
14 14
15 class TypeOfTestedWebsites: 15 class TypeOfTestedWebsites:
16 """An enum to specify which groups of tests to run.""" 16 """An enum to specify which groups of tests to run."""
17 # Runs only the disabled tests.
18 # TODO(vabr): Remove this option.
19 DISABLED_TESTS = 0
20 # Runs only the enabled tests.
21 ENABLED_TESTS = 1
22 # Runs all the tests. 17 # Runs all the tests.
23 ALL_TESTS = 2 18 ALL_TESTS = 0
24 # Runs a specified list of tests. 19 # Runs a specified list of tests.
25 LIST_OF_TESTS = 3 20 LIST_OF_TESTS = 1
26 21
27 def __init__(self): 22 def __init__(self):
28 pass 23 pass
29 24
30 25
31 class Alexa(WebsiteTest): 26 class Alexa(WebsiteTest):
32 27
33 def Login(self): 28 def Login(self):
34 self.GoTo("https://www.alexa.com/secure/login") 29 self.GoTo("https://www.alexa.com/secure/login")
35 self.FillUsernameInto("#email") 30 self.FillUsernameInto("#email")
(...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after
212 207
213 class Yandex(WebsiteTest): 208 class Yandex(WebsiteTest):
214 209
215 def Login(self): 210 def Login(self):
216 self.GoTo("https://mail.yandex.com") 211 self.GoTo("https://mail.yandex.com")
217 self.FillUsernameInto("#b-mail-domik-username11") 212 self.FillUsernameInto("#b-mail-domik-username11")
218 self.FillPasswordInto("#b-mail-domik-password11") 213 self.FillPasswordInto("#b-mail-domik-password11")
219 self.Click(".b-mail-button__button") 214 self.Click(".b-mail-button__button")
220 215
221 216
222 # Disabled tests.
223
224 # Fails due to test framework issue(?). 217 # Fails due to test framework issue(?).
225 class Aliexpress(WebsiteTest): 218 class Aliexpress(WebsiteTest):
226 219
227 def Login(self): 220 def Login(self):
228 self.GoTo("https://login.aliexpress.com/buyer.htm?return=http%3A%2F%2Fwww.al iexpress.com%2F") 221 self.GoTo("https://login.aliexpress.com/buyer.htm?return=http%3A%2F%2Fwww.al iexpress.com%2F")
229 self.WaitUntilDisplayed("iframe#alibaba-login-box") 222 self.WaitUntilDisplayed("iframe#alibaba-login-box")
230 frame = self.driver.find_element_by_css_selector("iframe#alibaba-login-box") 223 frame = self.driver.find_element_by_css_selector("iframe#alibaba-login-box")
231 self.driver.switch_to_frame(frame) 224 self.driver.switch_to_frame(frame)
232 self.FillUsernameInto("#fm-login-id") 225 self.FillUsernameInto("#fm-login-id")
233 self.FillPasswordInto("#fm-login-password") 226 self.FillPasswordInto("#fm-login-password")
(...skipping 213 matching lines...) Expand 10 before | Expand all | Expand 10 after
447 440
448 def Login(self): 441 def Login(self):
449 self.GoTo("http://www.ziddu.com/login.php") 442 self.GoTo("http://www.ziddu.com/login.php")
450 self.FillUsernameInto("#email") 443 self.FillUsernameInto("#email")
451 self.FillPasswordInto("#password") 444 self.FillPasswordInto("#password")
452 self.Click(".login input") 445 self.Click(".login input")
453 446
454 447
455 def Tests(environment, tests_to_run=None): 448 def Tests(environment, tests_to_run=None):
456 449
457 working_tests = { 450 all_tests = {
451 "163": One63("163"), # http://crbug.com/368690
452 "adobe": Adobe("adobe"), # Password saving not offered.
458 "alexa": Alexa("alexa"), 453 "alexa": Alexa("alexa"),
459 "dropbox": Dropbox("dropbox"),
460 "facebook": Facebook("facebook"),
461 "github": Github("github"),
462 "google": Google("google"),
463 "imgur": Imgur("imgur"),
464 "liveinternet": Liveinternet("liveinternet"),
465 "linkedin": Linkedin("linkedin"),
466 "mailru": Mailru("mailru"),
467 "nytimes": Nytimes("nytimes"),
468 "odnoklassniki": Odnoklassniki("odnoklassniki"),
469 "pinterest": Pinterest("pinterest"),
470 "reddit": Reddit("reddit", username_not_auto=True),
471 "tumblr": Tumblr("tumblr", username_not_auto=True),
472 "twitter": Twitter("twitter"),
473 "vkontakte": Vkontakte("vkontakte"),
474 "wikia": Wikia("wikia"),
475 "wikipedia": Wikipedia("wikipedia", username_not_auto=True),
476 "wordpress": Wordpress("wordpress"),
477 "yahoo": Yahoo("yahoo", username_not_auto=True),
478 "yandex": Yandex("yandex")
479 }
480
481 disabled_tests = {
482 "adobe": Adobe("adobe"), # Password saving not offered.
483 "aliexpress": Aliexpress("aliexpress"), # Fails due to test framework issue. 454 "aliexpress": Aliexpress("aliexpress"), # Fails due to test framework issue.
484 "amazon": Amazon("amazon"), # Bug not reproducible without test. 455 "amazon": Amazon("amazon"), # Bug not reproducible without test.
485 "ask": Ask("ask"), # Password not saved. 456 "ask": Ask("ask"), # Password not saved.
486 "baidu": Baidu("baidu"), # Password not saved. 457 "baidu": Baidu("baidu"), # Password not saved.
487 "cnn": Cnn("cnn"), # http://crbug.com/368690 458 "cnn": Cnn("cnn"), # http://crbug.com/368690
488 "craigslist": Craigslist("craigslist"), # Too many failed logins per time. 459 "craigslist": Craigslist("craigslist"), # Too many failed logins per time.
489 "dailymotion": Dailymotion("dailymotion"), # Crashes. 460 "dailymotion": Dailymotion("dailymotion"), # Crashes.
461 "dropbox": Dropbox("dropbox"),
490 "ebay": Ebay("ebay"), # http://crbug.com/368690 462 "ebay": Ebay("ebay"), # http://crbug.com/368690
491 "espn": Espn("espn"), # Iframe, password saved but not autofilled. 463 "espn": Espn("espn"), # Iframe, password saved but not autofilled.
464 "facebook": Facebook("facebook"),
492 "flipkart": Flipkart("flipkart"), # Fails due to test framework issue. 465 "flipkart": Flipkart("flipkart"), # Fails due to test framework issue.
466 "github": Github("github"),
467 "google": Google("google"),
468 "imgur": Imgur("imgur"),
493 "instagram": Instagram("instagram"), # Iframe, pw saved but not autofilled. 469 "instagram": Instagram("instagram"), # Iframe, pw saved but not autofilled.
470 "linkedin": Linkedin("linkedin"),
471 "liveinternet": Liveinternet("liveinternet"),
494 "live": Live("live", username_not_auto=True), # http://crbug.com/367768 472 "live": Live("live", username_not_auto=True), # http://crbug.com/367768
495 "163": One63("163"), # http://crbug.com/368690 473 "mailru": Mailru("mailru"),
474 "nytimes": Nytimes("nytimes"),
475 "odnoklassniki": Odnoklassniki("odnoklassniki"),
476 "pinterest": Pinterest("pinterest"),
477 "reddit": Reddit("reddit", username_not_auto=True),
496 "stackexchange": StackExchange("stackexchange"), # Iframe, not autofilled. 478 "stackexchange": StackExchange("stackexchange"), # Iframe, not autofilled.
479 "tumblr": Tumblr("tumblr", username_not_auto=True),
480 "twitter": Twitter("twitter"),
481 "vkontakte": Vkontakte("vkontakte"),
497 "vube": Vube("vube"), # http://crbug.com/368690 482 "vube": Vube("vube"), # http://crbug.com/368690
483 "wikia": Wikia("wikia"),
484 "wikipedia": Wikipedia("wikipedia", username_not_auto=True),
485 "wordpress": Wordpress("wordpress"),
486 "yahoo": Yahoo("yahoo", username_not_auto=True),
487 "yandex": Yandex("yandex"),
498 "ziddu": Ziddu("ziddu"), # Password not saved. 488 "ziddu": Ziddu("ziddu"), # Password not saved.
499 } 489 }
500 490
501 if tests_to_run: 491 if tests_to_run:
502 for test in tests_to_run: 492 for test in tests_to_run:
503 if (test not in working_tests.keys() and 493 if test not in all_tests.keys():
504 test not in disabled_tests.keys()):
505 print "Skip test: test {} is not in known tests".format(test) 494 print "Skip test: test {} is not in known tests".format(test)
melandory 2015/03/25 16:22:14 Since recent switch to logger, probably this print
vabr (Chromium) 2015/03/25 16:51:13 Good point. Because the value of this log is rathe
506 continue 495 continue
507 if test in working_tests.keys(): 496 test_class = all_tests[test]
508 test_class = working_tests[test]
509 else:
510 test_class = disabled_tests[test]
511 environment.AddWebsiteTest(test_class) 497 environment.AddWebsiteTest(test_class)
512 else: 498 else:
513 for test in working_tests.itervalues(): 499 for test in all_tests.itervalues():
514 environment.AddWebsiteTest(test) 500 environment.AddWebsiteTest(test)
515 for test in disabled_tests.itervalues():
516 environment.AddWebsiteTest(test, disabled=True)
517 501
melandory 2015/03/25 16:22:14 Optional: I would rewrite code in lines 490--500 i
vabr (Chromium) 2015/03/25 16:51:13 I like that, thanks for suggesting! Done.
518 502
519 def saveResults(environment_tests_results, environment_save_path): 503 def saveResults(environment_tests_results, environment_save_path):
520 """Save the test results in an xml file. 504 """Save the test results in an xml file.
521 505
522 Args: 506 Args:
523 environment_tests_results: A list of the TestResults that are going to be 507 environment_tests_results: A list of the TestResults that are going to be
524 saved. 508 saved.
525 environment_save_path: The file where the results are going to be saved. 509 environment_save_path: The file where the results are going to be saved.
526 If it's None, the results are not going to be stored. 510 If it's None, the results are not going to be stored.
527 Raises: 511 Raises:
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
574 environment_log_file) 558 environment_log_file)
575 559
576 # Test which care about the save-password prompt need the prompt 560 # Test which care about the save-password prompt need the prompt
577 # to be shown. Automatic password saving results in no prompt. 561 # to be shown. Automatic password saving results in no prompt.
578 run_prompt_tests = not enable_automatic_password_saving 562 run_prompt_tests = not enable_automatic_password_saving
579 563
580 Tests(environment, tests) 564 Tests(environment, tests)
581 565
582 if environment_tested_websites == TypeOfTestedWebsites.ALL_TESTS: 566 if environment_tested_websites == TypeOfTestedWebsites.ALL_TESTS:
583 environment.AllTests(run_prompt_tests) 567 environment.AllTests(run_prompt_tests)
584 elif environment_tested_websites == TypeOfTestedWebsites.DISABLED_TESTS:
585 environment.DisabledTests(run_prompt_tests)
586 elif environment_tested_websites == TypeOfTestedWebsites.LIST_OF_TESTS: 568 elif environment_tested_websites == TypeOfTestedWebsites.LIST_OF_TESTS:
587 environment.Test(tests, run_prompt_tests) 569 environment.Test(tests, run_prompt_tests)
588 elif environment_tested_websites == TypeOfTestedWebsites.ENABLED_TESTS:
589 environment.WorkingTests(run_prompt_tests)
590 else: 570 else:
591 raise Exception("Error: |environment_tested_websites| has to be one of the" 571 raise Exception("Error: |environment_tested_websites| has to be one of the"
592 "TypeOfTestedWebsites values") 572 "TypeOfTestedWebsites values")
593 573
594 574
595 environment.Quit() 575 environment.Quit()
596 return environment.tests_results 576 return environment.tests_results
597 577
598 # Tests setup. 578 # Tests setup.
599 if __name__ == "__main__": 579 if __name__ == "__main__":
(...skipping 10 matching lines...) Expand all
610 "--profile-path", action="store", dest="profile_path", 590 "--profile-path", action="store", dest="profile_path",
611 help="Set the profile path (required). You just need to choose a " 591 help="Set the profile path (required). You just need to choose a "
612 "temporary empty folder. If the folder is not empty all its content " 592 "temporary empty folder. If the folder is not empty all its content "
613 "is going to be removed.", 593 "is going to be removed.",
614 nargs=1, required=True) 594 nargs=1, required=True)
615 595
616 parser.add_argument( 596 parser.add_argument(
617 "--passwords-path", action="store", dest="passwords_path", 597 "--passwords-path", action="store", dest="passwords_path",
618 help="Set the usernames/passwords path (required).", nargs=1, 598 help="Set the usernames/passwords path (required).", nargs=1,
619 required=True) 599 required=True)
620 parser.add_argument("--all", action="store_true", dest="all",
621 help="Run all tests.")
622 parser.add_argument("--disabled", action="store_true", dest="disabled",
623 help="Run only disabled tests.")
624 parser.add_argument("--log", action="store", nargs=1, dest="log_level", 600 parser.add_argument("--log", action="store", nargs=1, dest="log_level",
625 help="Set log level.") 601 help="Set log level.")
626 parser.add_argument("--log-screen", action="store_true", dest="log_screen", 602 parser.add_argument("--log-screen", action="store_true", dest="log_screen",
627 help="Show log on the screen.") 603 help="Show log on the screen.")
628 parser.add_argument("--log-file", action="store", dest="log_file", 604 parser.add_argument("--log-file", action="store", dest="log_file",
629 help="Write the log in a file.", nargs=1) 605 help="Write the log in a file.", nargs=1)
630 parser.add_argument("--save-path", action="store", nargs=1, dest="save_path", 606 parser.add_argument("--save-path", action="store", nargs=1, dest="save_path",
631 help="Write the results in a file.") 607 help="Write the results in a file.")
632 parser.add_argument("tests", help="Tests to be run.", nargs="*") 608 parser.add_argument("tests", help="Tests to be run.", nargs="*")
633 609
634 args = parser.parse_args() 610 args = parser.parse_args()
635 611
636 passwords_path = args.passwords_path[0] 612 passwords_path = args.passwords_path[0]
637 613
638 if args.all: 614 tested_websites = TypeOfTestedWebsites.ALL_TESTS
639 tested_websites = TypeOfTestedWebsites.ALL_TESTS 615 if args.tests:
640 elif args.disabled:
641 tested_websites = TypeOfTestedWebsites.DISABLED_TESTS
642 elif args.tests:
643 tested_websites = TypeOfTestedWebsites.LIST_OF_TESTS 616 tested_websites = TypeOfTestedWebsites.LIST_OF_TESTS
644 else:
645 tested_websites = TypeOfTestedWebsites.ENABLED_TESTS
646 617
647 numeric_level = None 618 numeric_level = None
648 if args.log_level: 619 if args.log_level:
649 numeric_level = getattr(logging, args.log_level[0].upper(), None) 620 numeric_level = getattr(logging, args.log_level[0].upper(), None)
650 if not isinstance(numeric_level, int): 621 if not isinstance(numeric_level, int):
651 raise ValueError("Invalid log level: %s" % args.log_level[0]) 622 raise ValueError("Invalid log level: %s" % args.log_level[0])
652 623
653 log_file = None 624 log_file = None
654 if args.log_file: 625 if args.log_file:
655 log_file = args.log_file[0] 626 log_file = args.log_file[0]
(...skipping 22 matching lines...) Expand all
678 args.profile_path[0], 649 args.profile_path[0],
679 passwords_path, 650 passwords_path,
680 True, 651 True,
681 numeric_level, 652 numeric_level,
682 args.log_screen, 653 args.log_screen,
683 log_file, 654 log_file,
684 tested_websites, 655 tested_websites,
685 args.tests) 656 args.tests)
686 657
687 saveResults(tests_results, save_path) 658 saveResults(tests_results, save_path)
OLDNEW
« no previous file with comments | « components/test/data/password_manager/automated_tests/environment.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698