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

Side by Side Diff: components/test/data/autofill/automated_integration/autofill_test/suite.py

Issue 2116583004: Automated Autofill testing library + extension (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fixed indentation Created 4 years, 5 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
OLDNEW
(Empty)
1 # Copyright 2016 The Chromium Authors. All rights reserved.
2 # Use of this source code is governed by a BSD-style license that can be
3 # found in the LICENSE file.
4
5 """Chrome Autofill Test Flow
6
7 Execute a set of autofill tasks in a fresh ChromeDriver instance that has been
8 pre-loaded with some default profile.
9
10 Requires:
11 - Selenium python bindings
12 http://selenium-python.readthedocs.org/
13
14 - ChromeDriver
15 https://sites.google.com/a/chromium.org/chromedriver/downloads
16 The ChromeDriver executable must be available on the search PATH.
17
18 - Chrome
19 """
20
21 import importlib
22 import unittest
23
24 # Local Imports
25 from autofill_task.autofill_task import AutofillTask
26 from testdata import profile_data
27 from .case import AutofillTestCase
28
29
30 class AutofillTestSuite(unittest.TestSuite):
31 """Represents an aggregation of individual Autofill test cases.
32
33 Attributes:
34 user_data_dir: Path string for the writable directory in which profiles
35 should be stored.
36 chrome_binary: Path string to the Chrome binary that should be used by
37 ChromeDriver.
38
39 If None then it will use the PATH to find a binary.
40 test_class: Name of the test class that should be run.
41 If this is set, then only the specified class will be executed
42 module: The module to load test cases from. This is relative to the tasks
43 package.
44 profile: Dict of profile data that acts as the master source for
45 validating autofill behaviour. If not specified then default profile data
46 will be used from testdata.profile_data.
47 debug: Whether debug output should be printed (False if not specified).
48 """
49 def __init__(self, user_data_dir, chrome_binary=None, test_class=None,
50 module='sites', profile=None, debug=False):
51 if profile is None:
52 profile = profile_data.DEFAULT
53
54 super(AutofillTestSuite, self).__init__()
55 self._test_class = test_class
56 self._profile = profile
57 self._debug = debug
58
59 module = 'tasks.%s' % module
60
61 try:
62 importlib.import_module(module)
63 except ImportError:
64 print 'Unable to load %s from tasks.' % module
65 raise
66
67 self._generate_tests(user_data_dir, chrome_binary)
68
69 def _generate_tests(self, user_data_dir, chrome_binary=None):
70 task_classes = AutofillTask.__subclasses__()
71 tests = []
72
73 if self._test_class:
74 for task in task_classes:
75 if task.__name__ == self._test_class:
76 test = AutofillTestCase(task, user_data_dir, self._profile,
77 chrome_binary=chrome_binary,
78 debug=self._debug)
79 self.addTest(test)
80 return
81
82 raise ValueError('Autofill Test \'%s\' could not be found.' %
83 self._test_class)
84 else:
85 for task in task_classes:
86 tests.append(AutofillTestCase(task, user_data_dir, self._profile,
87 chrome_binary=chrome_binary,
88 debug=self._debug))
89
90 self.addTests(tests)
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698