| OLD | NEW |
| 1 #!/usr/bin/python | 1 #!/usr/bin/python |
| 2 | 2 |
| 3 # Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file | 3 # Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file |
| 4 # for details. All rights reserved. Use of this source code is governed by a | 4 # for details. All rights reserved. Use of this source code is governed by a |
| 5 # BSD-style license that can be found in the LICENSE file. | 5 # BSD-style license that can be found in the LICENSE file. |
| 6 # | 6 # |
| 7 | 7 |
| 8 """Script to actually open a browser and perform the test, and reports back with | 8 """Script to actually open a browser and perform the test, and reports back with |
| 9 the result. | 9 the result. |
| 10 """ | 10 """ |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 42 source = '' | 42 source = '' |
| 43 try: | 43 try: |
| 44 if is_perf: | 44 if is_perf: |
| 45 # We're running a performance test. | 45 # We're running a performance test. |
| 46 element = WebDriverWait(browser, float(timeout)).until(perf_test_done) | 46 element = WebDriverWait(browser, float(timeout)).until(perf_test_done) |
| 47 else: | 47 else: |
| 48 element = WebDriverWait(browser, float(timeout)).until( | 48 element = WebDriverWait(browser, float(timeout)).until( |
| 49 lambda driver : ('PASS' in driver.page_source) or | 49 lambda driver : ('PASS' in driver.page_source) or |
| 50 ('FAIL' in driver.page_source)) | 50 ('FAIL' in driver.page_source)) |
| 51 source = browser.page_source | 51 source = browser.page_source |
| 52 except selenium.common.exceptions.TimeoutException: |
| 53 source = 'FAIL (timeout)' |
| 52 finally: | 54 finally: |
| 53 # A timeout exception is thrown if nothing happens within the time limit. | 55 # A timeout exception is thrown if nothing happens within the time limit. |
| 54 if browser != 'chrome': | 56 if browser != 'chrome': |
| 55 browser.close() | 57 browser.close() |
| 56 try: | 58 try: |
| 57 browser.quit() | 59 browser.quit() |
| 58 except selenium.common.exceptions.WebDriverException: | 60 except selenium.common.exceptions.WebDriverException: |
| 59 #TODO(efortuna): figure out why this crashes.... and avoid? | 61 #TODO(efortuna): figure out why this crashes.... and avoid? |
| 60 pass | 62 pass |
| 61 return source | 63 return source |
| (...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 149 #TODO(efortuna): Access these elements in a nicer way using DOM parser. | 151 #TODO(efortuna): Access these elements in a nicer way using DOM parser. |
| 150 index = source.find('<body>') | 152 index = source.find('<body>') |
| 151 index += len('<body>') | 153 index += len('<body>') |
| 152 end_index = source.find('<script') | 154 end_index = source.find('<script') |
| 153 print source[index : end_index] | 155 print source[index : end_index] |
| 154 return 1 | 156 return 1 |
| 155 | 157 |
| 156 | 158 |
| 157 if __name__ == "__main__": | 159 if __name__ == "__main__": |
| 158 sys.exit(Main()) | 160 sys.exit(Main()) |
| OLD | NEW |