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

Unified 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « tools/testing/architecture.py ('k') | tools/testing/test_case.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tools/testing/run_selenium.py
===================================================================
--- tools/testing/run_selenium.py (revision 1522)
+++ tools/testing/run_selenium.py (working copy)
@@ -5,8 +5,12 @@
# BSD-style license that can be found in the LICENSE file.
#
-"""Script to actually open browsers and perform the test, and reports back with
-the result"""
+"""Script to actually open a browser and perform the test, and reports back with
+the result.
+Expects:
+ sys.argv[1] = html output file
+ sys.argv[2] = browser type (default = chrome)
+"""
import platform
import selenium
@@ -15,41 +19,41 @@
def runTestInBrowser(browser):
+ """Run the desired test in the browser, and wait for the test to complete."""
browser.get("file://" + sys.argv[1])
- element = WebDriverWait(browser, 10).until( \
- lambda driver : ('PASS' in driver.page_source) or \
- ('FAIL' in driver.page_source))
- source = browser.page_source
- browser.close()
+ source = ''
+ try:
+ element = WebDriverWait(browser, 10).until( \
+ lambda driver : ('PASS' in driver.page_source) or \
+ ('FAIL' in driver.page_source))
+ source = browser.page_source
+ finally:
+ # A timeout exception is thrown if nothing happens within the time limit.
+ browser.close()
return source
def Main():
- browser = selenium.webdriver.Firefox() # Get local session of firefox
- firefox_source = runTestInBrowser(browser)
-
- # Note: you need ChromeDriver in your path to run chrome, in addition to
- #installing Chrome.
- # TODO(efortuna): Currently disabled for ease of setup for running on other
- # developer machines. Uncomment when frog is robust enough to be tested on
- # multiple platforms at once.
- #browser = selenium.webdriver.Chrome()
- #chrome_source = runTestInBrowser(browser)
-
- ie_source = ''
- if platform.system() == 'Windows':
+ # Note: you need ChromeDriver *in your path* to run Chrome, in addition to
+ # installing Chrome.
+ browser = None
+ if sys.argv[2] == 'chrome':
+ browser = selenium.webdriver.Chrome()
+ elif sys.argv[2] == 'ff':
+ browser = selenium.webdriver.Firefox()
+ elif sys.argv[2] == 'ie' and platform.system() == 'Windows':
browser = selenium.webdriver.Ie()
- ie_source = runTestInBrowser(browser)
+ else:
+ raise Exception('Incompatible browser and platform combination.')
+ source = runTestInBrowser(browser)
- #TODO(efortuna): Test if all three return correct responses. If not, throw
- #error particular to that browser.
- if ('PASS' in firefox_source):
+ if ('PASS' in source):
print 'Content-Type: text/plain\nPASS'
return 0
else:
- index = firefox_source.find('<body>')
+ index = source.find('<body>')
index += len('<body>')
- end_index = firefox_source.find('<script')
- print firefox_source[index : end_index]
+ end_index = source.find('<script')
+ print source[index : end_index]
return 1
« 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