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 708 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
719 # Set size first so that the window isn't moved offscreen. | 719 # Set size first so that the window isn't moved offscreen. |
720 # See https://code.google.com/p/chromedriver/issues/detail?id=297. | 720 # See https://code.google.com/p/chromedriver/issues/detail?id=297. |
721 self._driver.SetWindowSize(600, 400) | 721 self._driver.SetWindowSize(600, 400) |
722 self._driver.SetWindowPosition(100, 200) | 722 self._driver.SetWindowPosition(100, 200) |
723 self.assertEquals([100, 200], self._driver.GetWindowPosition()) | 723 self.assertEquals([100, 200], self._driver.GetWindowPosition()) |
724 self.assertEquals([600, 400], self._driver.GetWindowSize()) | 724 self.assertEquals([600, 400], self._driver.GetWindowSize()) |
725 | 725 |
726 def testConsoleLogSources(self): | 726 def testConsoleLogSources(self): |
727 self._driver.Load(self.GetHttpUrlForFile('/chromedriver/console_log.html')) | 727 self._driver.Load(self.GetHttpUrlForFile('/chromedriver/console_log.html')) |
728 logs = self._driver.GetLog('browser') | 728 logs = self._driver.GetLog('browser') |
729 self.assertEquals(len(logs), 2) | 729 |
730 self.assertEquals(logs[0]['source'], 'network') | 730 self.assertEqual('network', logs[0]['source']) |
731 self.assertEquals(logs[1]['source'], 'javascript') | 731 self.assertTrue('nonexistent.png' in logs[0]['message']) |
732 self.assertTrue('404' in logs[0]['message']) | |
733 | |
734 self.assertEqual('javascript', logs[1]['source']) | |
735 self.assertTrue('TypeError' in logs[1]['message']) | |
736 | |
737 # Sometimes, we also get an error for a missing favicon. | |
stgao
2015/01/23 19:45:55
Just FYI: another idea is to add a dummy favicon t
| |
738 if len(logs) > 2: | |
739 self.assertEqual('network', logs[2]['source']) | |
740 self.assertTrue('favicon.ico' in logs[2]['message']) | |
741 self.assertTrue('404' in logs[2]['message']) | |
742 self.assertEqual(3, len(logs)) | |
743 else: | |
744 self.assertEqual(2, len(logs)) | |
732 | 745 |
733 def testAutoReporting(self): | 746 def testAutoReporting(self): |
734 self.assertFalse(self._driver.IsAutoReporting()) | 747 self.assertFalse(self._driver.IsAutoReporting()) |
735 self._driver.SetAutoReporting(True) | 748 self._driver.SetAutoReporting(True) |
736 self.assertTrue(self._driver.IsAutoReporting()) | 749 self.assertTrue(self._driver.IsAutoReporting()) |
737 url = self.GetHttpUrlForFile('/chromedriver/console_log.html') | 750 url = self.GetHttpUrlForFile('/chromedriver/console_log.html') |
738 self.assertRaisesRegexp(chromedriver.UnknownError, | 751 self.assertRaisesRegexp(chromedriver.UnknownError, |
739 '.*(404|Failed to load resource).*', | 752 '.*(404|Failed to load resource).*', |
740 self._driver.Load, | 753 self._driver.Load, |
741 url) | 754 url) |
(...skipping 690 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1432 | 1445 |
1433 all_tests_suite = unittest.defaultTestLoader.loadTestsFromModule( | 1446 all_tests_suite = unittest.defaultTestLoader.loadTestsFromModule( |
1434 sys.modules[__name__]) | 1447 sys.modules[__name__]) |
1435 tests = unittest_util.FilterTestSuite(all_tests_suite, options.filter) | 1448 tests = unittest_util.FilterTestSuite(all_tests_suite, options.filter) |
1436 ChromeDriverTest.GlobalSetUp() | 1449 ChromeDriverTest.GlobalSetUp() |
1437 MobileEmulationCapabilityTest.GlobalSetUp() | 1450 MobileEmulationCapabilityTest.GlobalSetUp() |
1438 result = unittest.TextTestRunner(stream=sys.stdout, verbosity=2).run(tests) | 1451 result = unittest.TextTestRunner(stream=sys.stdout, verbosity=2).run(tests) |
1439 ChromeDriverTest.GlobalTearDown() | 1452 ChromeDriverTest.GlobalTearDown() |
1440 MobileEmulationCapabilityTest.GlobalTearDown() | 1453 MobileEmulationCapabilityTest.GlobalTearDown() |
1441 sys.exit(len(result.failures) + len(result.errors)) | 1454 sys.exit(len(result.failures) + len(result.errors)) |
OLD | NEW |