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 optparse | 9 import optparse |
10 import subprocess | 10 import subprocess |
(...skipping 689 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
700 | 700 |
701 def testConnectToExistingBrowser(self): | 701 def testConnectToExistingBrowser(self): |
702 port = self.FindFreePort() | 702 port = self.FindFreePort() |
703 temp_dir = util.MakeTempDir() | 703 temp_dir = util.MakeTempDir() |
704 process = subprocess.Popen([_CHROME_BINARY, | 704 process = subprocess.Popen([_CHROME_BINARY, |
705 '--remote-debugging-port=%d' % port, | 705 '--remote-debugging-port=%d' % port, |
706 '--user-data-dir=%s' % temp_dir]) | 706 '--user-data-dir=%s' % temp_dir]) |
707 if process is None: | 707 if process is None: |
708 raise RuntimeError('Chrome could not be started with debugging port') | 708 raise RuntimeError('Chrome could not be started with debugging port') |
709 try: | 709 try: |
710 hostAndPort = '127.0.0.1:%d' % port | 710 driver = self.CreateDriver(debugger_address='127.0.0.1:%d' % port) |
711 driver = self.CreateDriver(chrome_existing_browser=hostAndPort) | |
712 driver.ExecuteScript('console.info("%s")' % 'connecting at %d!' % port) | 711 driver.ExecuteScript('console.info("%s")' % 'connecting at %d!' % port) |
713 driver.Quit() | 712 driver.Quit() |
714 finally: | 713 finally: |
715 process.terminate() | 714 process.terminate() |
716 | 715 |
717 def FindFreePort(self): | 716 def FindFreePort(self): |
718 for port in range(10000, 10100): | 717 for port in range(10000, 10100): |
719 try: | 718 try: |
720 socket.create_connection(('127.0.0.1', port), 0.2).close() | 719 socket.create_connection(('127.0.0.1', port), 0.2).close() |
721 except socket.error: | 720 except socket.error: |
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
837 negative_filter = _GetDesktopNegativeFilter(options.chrome_version) | 836 negative_filter = _GetDesktopNegativeFilter(options.chrome_version) |
838 options.filter = '*-' + ':__main__.'.join([''] + negative_filter) | 837 options.filter = '*-' + ':__main__.'.join([''] + negative_filter) |
839 | 838 |
840 all_tests_suite = unittest.defaultTestLoader.loadTestsFromModule( | 839 all_tests_suite = unittest.defaultTestLoader.loadTestsFromModule( |
841 sys.modules[__name__]) | 840 sys.modules[__name__]) |
842 tests = unittest_util.FilterTestSuite(all_tests_suite, options.filter) | 841 tests = unittest_util.FilterTestSuite(all_tests_suite, options.filter) |
843 ChromeDriverTest.GlobalSetUp() | 842 ChromeDriverTest.GlobalSetUp() |
844 result = unittest.TextTestRunner(stream=sys.stdout, verbosity=2).run(tests) | 843 result = unittest.TextTestRunner(stream=sys.stdout, verbosity=2).run(tests) |
845 ChromeDriverTest.GlobalTearDown() | 844 ChromeDriverTest.GlobalTearDown() |
846 sys.exit(len(result.failures) + len(result.errors)) | 845 sys.exit(len(result.failures) + len(result.errors)) |
OLD | NEW |