OLD | NEW |
1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
2 # Copyright 2013 The Chromium Authors. All rights reserved. | 2 # Copyright 2013 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 """End to end tests for ChromeDriver.""" | 6 """End to end tests for ChromeDriver.""" |
7 | 7 |
8 import base64 | 8 import base64 |
9 import json | 9 import json |
10 import math | 10 import math |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
43 from pylib import valgrind_tools | 43 from pylib import valgrind_tools |
44 from pylib.device import device_utils | 44 from pylib.device import device_utils |
45 | 45 |
46 | 46 |
47 _NEGATIVE_FILTER = [ | 47 _NEGATIVE_FILTER = [ |
48 # https://code.google.com/p/chromedriver/issues/detail?id=213 | 48 # https://code.google.com/p/chromedriver/issues/detail?id=213 |
49 'ChromeDriverTest.testClickElementInSubFrame', | 49 'ChromeDriverTest.testClickElementInSubFrame', |
50 # This test is flaky since it uses setTimeout. | 50 # This test is flaky since it uses setTimeout. |
51 # Re-enable once crbug.com/177511 is fixed and we can remove setTimeout. | 51 # Re-enable once crbug.com/177511 is fixed and we can remove setTimeout. |
52 'ChromeDriverTest.testAlert', | 52 'ChromeDriverTest.testAlert', |
53 # Enable per-browser when http://crbug.com/456324 is fixed. | |
54 'ChromeDriverTest.testEmulateNetworkConditionsOffline', | |
55 # This test is too flaky on the bots, but seems to run perfectly fine | 53 # This test is too flaky on the bots, but seems to run perfectly fine |
56 # on developer workstations. | 54 # on developer workstations. |
57 'ChromeDriverTest.testEmulateNetworkConditionsNameSpeed', | 55 'ChromeDriverTest.testEmulateNetworkConditionsNameSpeed', |
58 'ChromeDriverTest.testEmulateNetworkConditionsSpeed', | 56 'ChromeDriverTest.testEmulateNetworkConditionsSpeed', |
59 ] | 57 ] |
60 | 58 |
61 _VERSION_SPECIFIC_FILTER = {} | 59 _VERSION_SPECIFIC_FILTER = {} |
62 _VERSION_SPECIFIC_FILTER['HEAD'] = [ | 60 _VERSION_SPECIFIC_FILTER['HEAD'] = [ |
63 # https://code.google.com/p/chromedriver/issues/detail?id=992 | 61 # https://code.google.com/p/chromedriver/issues/detail?id=992 |
64 'ChromeDownloadDirTest.testDownloadDirectoryOverridesExistingPreferences', | 62 'ChromeDownloadDirTest.testDownloadDirectoryOverridesExistingPreferences', |
(...skipping 810 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
875 "<html><body>%s</body></html>" % _1_megabyte) | 873 "<html><body>%s</body></html>" % _1_megabyte) |
876 start = time.time() | 874 start = time.time() |
877 self._driver.Load(self._http_server.GetUrl() + '/1MB') | 875 self._driver.Load(self._http_server.GetUrl() + '/1MB') |
878 finish = time.time() | 876 finish = time.time() |
879 duration = finish - start | 877 duration = finish - start |
880 actual_throughput_kbps = 1024 / duration | 878 actual_throughput_kbps = 1024 / duration |
881 self.assertLessEqual(actual_throughput_kbps, throughput_kbps * 1.5) | 879 self.assertLessEqual(actual_throughput_kbps, throughput_kbps * 1.5) |
882 self.assertGreaterEqual(actual_throughput_kbps, throughput_kbps / 1.5) | 880 self.assertGreaterEqual(actual_throughput_kbps, throughput_kbps / 1.5) |
883 | 881 |
884 def testEmulateNetworkConditionsOffline(self): | 882 def testEmulateNetworkConditionsOffline(self): |
885 self._driver.SetNetworkConditions(5, 2048, 2048, offline=True) | 883 # A workaround for crbug.com/177511; when setting offline, the throughputs |
| 884 # must be 0. |
| 885 self._driver.SetNetworkConditions(0, 0, 0, offline=True) |
886 self._driver.Load(self.GetHttpUrlForFile('/chromedriver/page_test.html')) | 886 self._driver.Load(self.GetHttpUrlForFile('/chromedriver/page_test.html')) |
887 self.assertIn('is not available', self._driver.GetTitle()) | 887 self.assertIn('is not available', self._driver.GetTitle()) |
888 | 888 |
889 def testShadowDomFindElementWithSlashDeep(self): | 889 def testShadowDomFindElementWithSlashDeep(self): |
890 """Checks that chromedriver can find elements in a shadow DOM using /deep/ | 890 """Checks that chromedriver can find elements in a shadow DOM using /deep/ |
891 css selectors.""" | 891 css selectors.""" |
892 self._driver.Load(self.GetHttpUrlForFile( | 892 self._driver.Load(self.GetHttpUrlForFile( |
893 '/chromedriver/shadow_dom_test.html')) | 893 '/chromedriver/shadow_dom_test.html')) |
894 self.assertTrue(self._driver.FindElement("css", "* /deep/ #olderTextBox")) | 894 self.assertTrue(self._driver.FindElement("css", "* /deep/ #olderTextBox")) |
895 | 895 |
(...skipping 651 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1547 | 1547 |
1548 all_tests_suite = unittest.defaultTestLoader.loadTestsFromModule( | 1548 all_tests_suite = unittest.defaultTestLoader.loadTestsFromModule( |
1549 sys.modules[__name__]) | 1549 sys.modules[__name__]) |
1550 tests = unittest_util.FilterTestSuite(all_tests_suite, options.filter) | 1550 tests = unittest_util.FilterTestSuite(all_tests_suite, options.filter) |
1551 ChromeDriverTest.GlobalSetUp() | 1551 ChromeDriverTest.GlobalSetUp() |
1552 MobileEmulationCapabilityTest.GlobalSetUp() | 1552 MobileEmulationCapabilityTest.GlobalSetUp() |
1553 result = unittest.TextTestRunner(stream=sys.stdout, verbosity=2).run(tests) | 1553 result = unittest.TextTestRunner(stream=sys.stdout, verbosity=2).run(tests) |
1554 ChromeDriverTest.GlobalTearDown() | 1554 ChromeDriverTest.GlobalTearDown() |
1555 MobileEmulationCapabilityTest.GlobalTearDown() | 1555 MobileEmulationCapabilityTest.GlobalTearDown() |
1556 sys.exit(len(result.failures) + len(result.errors)) | 1556 sys.exit(len(result.failures) + len(result.errors)) |
OLD | NEW |