| OLD | NEW |
| (Empty) | |
| 1 #!/usr/bin/env python |
| 2 # Copyright 2016 The Chromium Authors. All rights reserved. |
| 3 # Use of this source code is governed by a BSD-style license that can be |
| 4 # found in the LICENSE file. |
| 5 |
| 6 """Autofill automated integration test runner |
| 7 |
| 8 Allows you to run integration test(s) for Autofill. |
| 9 At this time only a limited set of websites are supported. |
| 10 |
| 11 Requires: |
| 12 - Selenium python bindings |
| 13 http://selenium-python.readthedocs.org/ |
| 14 |
| 15 - ChromeDriver |
| 16 https://sites.google.com/a/chromium.org/chromedriver/downloads |
| 17 The ChromeDriver executable must be available on the search PATH. |
| 18 |
| 19 - Chrome (>= 53) |
| 20 |
| 21 - Write access to '/var/google/autofill/chrome_user_data' |
| 22 |
| 23 Instructions: |
| 24 - Add tests to tasks/sites.py (or a new module in tasks/) |
| 25 - Run main.py -h to view the available flags. |
| 26 - All tests in tasks/sites.py will be run in the default chrome binary if |
| 27 no flags are specified. |
| 28 """ |
| 29 |
| 30 import argparse |
| 31 import types |
| 32 import sys |
| 33 |
| 34 # Local Imports |
| 35 from autofill_test.suite import AutofillTestSuite |
| 36 from autofill_test.runner import AutofillTestRunner |
| 37 |
| 38 USER_DATA_DIR = '/var/google/autofill/chrome_user_data' |
| 39 |
| 40 |
| 41 def parse_args(): |
| 42 description = 'Allows you to run integration test(s) for Autofill.' |
| 43 epilog = ('All tests in tasks/sites.py will be run in the default chrome ' |
| 44 'binary if no flags are specified. At this time only a limited ' |
| 45 'set of websites are supported.') |
| 46 |
| 47 parser = argparse.ArgumentParser(description=description, epilog=epilog) |
| 48 parser.add_argument('--user-data-dir', dest='user_data_dir', metavar='PATH', |
| 49 default=USER_DATA_DIR, help='chrome user data directory') |
| 50 parser.add_argument('--chrome-binary', dest='chrome_binary', metavar='PATH', |
| 51 default=None, help='chrome binary location') |
| 52 parser.add_argument('--module', default='sites', help='task module name') |
| 53 parser.add_argument('--test', dest='test_class', |
| 54 help='name of a specific test to run') |
| 55 parser.add_argument('-d', '--debug', action='store_true', default=False, |
| 56 help='print additional information, useful for debugging') |
| 57 |
| 58 args = parser.parse_args() |
| 59 |
| 60 args.debug = bool(args.debug) |
| 61 |
| 62 return args |
| 63 |
| 64 |
| 65 def run(args): |
| 66 if args.debug: |
| 67 print 'Running with arguments: %s' % vars(args) |
| 68 |
| 69 try: |
| 70 test_suite = AutofillTestSuite(args.user_data_dir, |
| 71 chrome_binary=args.chrome_binary, |
| 72 test_class=args.test_class, |
| 73 module=args.module, debug=args.debug) |
| 74 verbosity = 2 if args.debug else 1 |
| 75 runner = AutofillTestRunner(verbosity=verbosity) |
| 76 runner.run(test_suite) |
| 77 except ImportError as e: |
| 78 print 'Test Execution failed. %s' % str(e) |
| 79 except Exception as e: |
| 80 raise |
| 81 |
| 82 |
| 83 if __name__ == '__main__': |
| 84 args = parse_args() |
| 85 run(args) |
| OLD | NEW |