OLD | NEW |
(Empty) | |
| 1 #!/usr/bin/python |
| 2 |
| 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 |
| 5 # BSD-style license that can be found in the LICENSE file. |
| 6 # |
| 7 |
| 8 """Script to actually open browsers and perform the test, and reports back with |
| 9 the result""" |
| 10 |
| 11 import platform |
| 12 import selenium |
| 13 from selenium.webdriver.support.ui import WebDriverWait |
| 14 import sys |
| 15 |
| 16 |
| 17 def runTestInBrowser(browser): |
| 18 browser.get("file://" + sys.argv[1]) |
| 19 element = WebDriverWait(browser, 10).until( \ |
| 20 lambda driver : ('PASS' in driver.page_source) or \ |
| 21 ('FAIL' in driver.page_source)) |
| 22 source = browser.page_source |
| 23 browser.close() |
| 24 return source |
| 25 |
| 26 def Main(): |
| 27 browser = selenium.webdriver.Firefox() # Get local session of firefox |
| 28 firefox_source = runTestInBrowser(browser) |
| 29 |
| 30 # Note: you need ChromeDriver in your path to run chrome, in addition to |
| 31 #installing Chrome. |
| 32 # TODO(efortuna): Currently disabled for ease of setup for running on other |
| 33 # developer machines. Uncomment when frog is robust enough to be tested on |
| 34 # multiple platforms at once. |
| 35 #browser = selenium.webdriver.Chrome() |
| 36 #chrome_source = runTestInBrowser(browser) |
| 37 |
| 38 ie_source = '' |
| 39 if platform.system() == 'Windows': |
| 40 browser = selenium.webdriver.Ie() |
| 41 ie_source = runTestInBrowser(browser) |
| 42 |
| 43 #TODO(efortuna): Test if all three return correct responses. If not, throw |
| 44 #error particular to that browser. |
| 45 if ('PASS' in firefox_source): |
| 46 print 'Content-Type: text/plain\nPASS' |
| 47 return 0 |
| 48 else: |
| 49 index = firefox_source.find('<body>') |
| 50 index += len('<body>') |
| 51 end_index = firefox_source.find('<script') |
| 52 print firefox_source[index : end_index] |
| 53 return 1 |
| 54 |
| 55 |
| 56 if __name__ == "__main__": |
| 57 sys.exit(Main()) |
OLD | NEW |