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

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: Comments addressed Created 5 years, 8 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 tests_to_run = tests_to_run or all_tests.keys()
502 for test in tests_to_run: 492 for test_name in tests_to_run:
503 if (test not in working_tests.keys() and 493 if test_name in all_tests.keys():
504 test not in disabled_tests.keys()): 494 environment.AddWebsiteTest(all_tests[test_name])
505 print "Skip test: test {} is not in known tests".format(test)
506 continue
507 if test in working_tests.keys():
508 test_class = working_tests[test]
509 else:
510 test_class = disabled_tests[test]
511 environment.AddWebsiteTest(test_class)
512 else:
513 for test in working_tests.itervalues():
514 environment.AddWebsiteTest(test)
515 for test in disabled_tests.itervalues():
516 environment.AddWebsiteTest(test, disabled=True)
517 495
518 496
519 def saveResults(environment_tests_results, environment_save_path): 497 def saveResults(environment_tests_results, environment_save_path):
520 """Save the test results in an xml file. 498 """Save the test results in an xml file.
521 499
522 Args: 500 Args:
523 environment_tests_results: A list of the TestResults that are going to be 501 environment_tests_results: A list of the TestResults that are going to be
524 saved. 502 saved.
525 environment_save_path: The file where the results are going to be saved. 503 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. 504 If it's None, the results are not going to be stored.
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
574 environment_log_file) 552 environment_log_file)
575 553
576 # Test which care about the save-password prompt need the prompt 554 # Test which care about the save-password prompt need the prompt
577 # to be shown. Automatic password saving results in no prompt. 555 # to be shown. Automatic password saving results in no prompt.
578 run_prompt_tests = not enable_automatic_password_saving 556 run_prompt_tests = not enable_automatic_password_saving
579 557
580 Tests(environment, tests) 558 Tests(environment, tests)
581 559
582 if environment_tested_websites == TypeOfTestedWebsites.ALL_TESTS: 560 if environment_tested_websites == TypeOfTestedWebsites.ALL_TESTS:
583 environment.AllTests(run_prompt_tests) 561 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: 562 elif environment_tested_websites == TypeOfTestedWebsites.LIST_OF_TESTS:
587 environment.Test(tests, run_prompt_tests) 563 environment.Test(tests, run_prompt_tests)
588 elif environment_tested_websites == TypeOfTestedWebsites.ENABLED_TESTS:
589 environment.WorkingTests(run_prompt_tests)
590 else: 564 else:
591 raise Exception("Error: |environment_tested_websites| has to be one of the" 565 raise Exception("Error: |environment_tested_websites| has to be one of the"
592 "TypeOfTestedWebsites values") 566 "TypeOfTestedWebsites values")
593 567
594 568
595 environment.Quit() 569 environment.Quit()
596 return environment.tests_results 570 return environment.tests_results
597 571
598 # Tests setup. 572 # Tests setup.
599 if __name__ == "__main__": 573 if __name__ == "__main__":
(...skipping 10 matching lines...) Expand all
610 "--profile-path", action="store", dest="profile_path", 584 "--profile-path", action="store", dest="profile_path",
611 help="Set the profile path (required). You just need to choose a " 585 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 " 586 "temporary empty folder. If the folder is not empty all its content "
613 "is going to be removed.", 587 "is going to be removed.",
614 nargs=1, required=True) 588 nargs=1, required=True)
615 589
616 parser.add_argument( 590 parser.add_argument(
617 "--passwords-path", action="store", dest="passwords_path", 591 "--passwords-path", action="store", dest="passwords_path",
618 help="Set the usernames/passwords path (required).", nargs=1, 592 help="Set the usernames/passwords path (required).", nargs=1,
619 required=True) 593 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", 594 parser.add_argument("--log", action="store", nargs=1, dest="log_level",
625 help="Set log level.") 595 help="Set log level.")
626 parser.add_argument("--log-screen", action="store_true", dest="log_screen", 596 parser.add_argument("--log-screen", action="store_true", dest="log_screen",
627 help="Show log on the screen.") 597 help="Show log on the screen.")
628 parser.add_argument("--log-file", action="store", dest="log_file", 598 parser.add_argument("--log-file", action="store", dest="log_file",
629 help="Write the log in a file.", nargs=1) 599 help="Write the log in a file.", nargs=1)
630 parser.add_argument("--save-path", action="store", nargs=1, dest="save_path", 600 parser.add_argument("--save-path", action="store", nargs=1, dest="save_path",
631 help="Write the results in a file.") 601 help="Write the results in a file.")
632 parser.add_argument("tests", help="Tests to be run.", nargs="*") 602 parser.add_argument("tests", help="Tests to be run.", nargs="*")
633 603
634 args = parser.parse_args() 604 args = parser.parse_args()
635 605
636 passwords_path = args.passwords_path[0] 606 passwords_path = args.passwords_path[0]
637 607
638 if args.all: 608 tested_websites = TypeOfTestedWebsites.ALL_TESTS
639 tested_websites = TypeOfTestedWebsites.ALL_TESTS 609 if args.tests:
640 elif args.disabled:
641 tested_websites = TypeOfTestedWebsites.DISABLED_TESTS
642 elif args.tests:
643 tested_websites = TypeOfTestedWebsites.LIST_OF_TESTS 610 tested_websites = TypeOfTestedWebsites.LIST_OF_TESTS
644 else:
645 tested_websites = TypeOfTestedWebsites.ENABLED_TESTS
646 611
647 numeric_level = None 612 numeric_level = None
648 if args.log_level: 613 if args.log_level:
649 numeric_level = getattr(logging, args.log_level[0].upper(), None) 614 numeric_level = getattr(logging, args.log_level[0].upper(), None)
650 if not isinstance(numeric_level, int): 615 if not isinstance(numeric_level, int):
651 raise ValueError("Invalid log level: %s" % args.log_level[0]) 616 raise ValueError("Invalid log level: %s" % args.log_level[0])
652 617
653 log_file = None 618 log_file = None
654 if args.log_file: 619 if args.log_file:
655 log_file = args.log_file[0] 620 log_file = args.log_file[0]
(...skipping 22 matching lines...) Expand all
678 args.profile_path[0], 643 args.profile_path[0],
679 passwords_path, 644 passwords_path,
680 True, 645 True,
681 numeric_level, 646 numeric_level,
682 args.log_screen, 647 args.log_screen,
683 log_file, 648 log_file,
684 tested_websites, 649 tested_websites,
685 args.tests) 650 args.tests)
686 651
687 saveResults(tests_results, save_path) 652 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