Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(208)

Side by Side Diff: tools/testing/run_selenium.py

Issue 8566021: Made changes to the test architecture so that we can run frameworks other than (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: '' Created 9 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « tools/testing/architecture.py ('k') | tools/testing/test_case.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 browsers 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 Expects:
11 sys.argv[1] = html output file
12 sys.argv[2] = browser type (default = chrome)
13 """
10 14
11 import platform 15 import platform
12 import selenium 16 import selenium
13 from selenium.webdriver.support.ui import WebDriverWait 17 from selenium.webdriver.support.ui import WebDriverWait
14 import sys 18 import sys
15 19
16 20
17 def runTestInBrowser(browser): 21 def runTestInBrowser(browser):
22 """Run the desired test in the browser, and wait for the test to complete."""
18 browser.get("file://" + sys.argv[1]) 23 browser.get("file://" + sys.argv[1])
19 element = WebDriverWait(browser, 10).until( \ 24 source = ''
20 lambda driver : ('PASS' in driver.page_source) or \ 25 try:
21 ('FAIL' in driver.page_source)) 26 element = WebDriverWait(browser, 10).until( \
22 source = browser.page_source 27 lambda driver : ('PASS' in driver.page_source) or \
23 browser.close() 28 ('FAIL' in driver.page_source))
29 source = browser.page_source
30 finally:
31 # A timeout exception is thrown if nothing happens within the time limit.
32 browser.close()
24 return source 33 return source
25 34
26 def Main(): 35 def Main():
27 browser = selenium.webdriver.Firefox() # Get local session of firefox 36 # Note: you need ChromeDriver *in your path* to run Chrome, in addition to
28 firefox_source = runTestInBrowser(browser) 37 # installing Chrome.
38 browser = None
39 if sys.argv[2] == 'chrome':
40 browser = selenium.webdriver.Chrome()
41 elif sys.argv[2] == 'ff':
42 browser = selenium.webdriver.Firefox()
43 elif sys.argv[2] == 'ie' and platform.system() == 'Windows':
44 browser = selenium.webdriver.Ie()
45 else:
46 raise Exception('Incompatible browser and platform combination.')
47 source = runTestInBrowser(browser)
29 48
30 # Note: you need ChromeDriver in your path to run chrome, in addition to 49 if ('PASS' in source):
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' 50 print 'Content-Type: text/plain\nPASS'
47 return 0 51 return 0
48 else: 52 else:
49 index = firefox_source.find('<body>') 53 index = source.find('<body>')
50 index += len('<body>') 54 index += len('<body>')
51 end_index = firefox_source.find('<script') 55 end_index = source.find('<script')
52 print firefox_source[index : end_index] 56 print source[index : end_index]
53 return 1 57 return 1
54 58
55 59
56 if __name__ == "__main__": 60 if __name__ == "__main__":
57 sys.exit(Main()) 61 sys.exit(Main())
OLDNEW
« no previous file with comments | « tools/testing/architecture.py ('k') | tools/testing/test_case.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698