Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(40)

Side by Side Diff: test/browser.py

Issue 40190043: Add the ability to run local browser tests.
Patch Set: Created 11 years, 3 months ago
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
View unified diff | Download patch
OLDNEW
1 # This file is part of the Juju GUI, which lets users view and manage Juju 1 # This file is part of the Juju GUI, which lets users view and manage Juju
2 # environments within a graphical interface (https://launchpad.net/juju-gui). 2 # environments within a graphical interface (https://launchpad.net/juju-gui).
3 # Copyright (C) 2012-2013 Canonical Ltd. 3 # Copyright (C) 2012-2013 Canonical Ltd.
4 # 4 #
5 # This program is free software: you can redistribute it and/or modify it under 5 # This program is free software: you can redistribute it and/or modify it under
6 # the terms of the GNU Affero General Public License version 3, as published by 6 # the terms of the GNU Affero General Public License version 3, as published by
7 # the Free Software Foundation. 7 # the Free Software Foundation.
8 # 8 #
9 # This program is distributed in the hope that it will be useful, but WITHOUT 9 # This program is distributed in the hope that it will be useful, but WITHOUT
10 # ANY WARRANTY; without even the implied warranties of MERCHANTABILITY, 10 # ANY WARRANTY; without even the implied warranties of MERCHANTABILITY,
(...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after
204 # problematic (i.e. connection errors) when switching from the sandbox 204 # problematic (i.e. connection errors) when switching from the sandbox
205 # mode back to the staging backend. 205 # mode back to the staging backend.
206 local_prefix = 'local-' 206 local_prefix = 'local-'
207 if browser_name.startswith(local_prefix): 207 if browser_name.startswith(local_prefix):
208 # If the browser name has the "local-" prefix, i.e. "local-chrome', 208 # If the browser name has the "local-" prefix, i.e. "local-chrome',
209 # "local-firefox" or "local-ie", start the associated local driver. 209 # "local-firefox" or "local-ie", start the associated local driver.
210 name = browser_name[len(local_prefix):] 210 name = browser_name[len(local_prefix):]
211 capabilities = get_capabilities(name) 211 capabilities = get_capabilities(name)
212 driver = make_local_driver(name, capabilities) 212 driver = make_local_driver(name, capabilities)
213 cls.remote_driver = False 213 cls.remote_driver = False
214 printerr('* Platform: local {}'.format(get_platform(driver)))
benji 2013/12/10 15:50:31 This was annoying and non-useful.
215 else: 214 else:
216 # Otherwise, set up a Saucelabs remote driver. 215 # Otherwise, set up a Saucelabs remote driver.
217 capabilities = get_capabilities(browser_name) 216 capabilities = get_capabilities(browser_name)
218 user = getpass.getuser() 217 user = getpass.getuser()
219 capabilities.update({'name': 'Juju GUI', 'tags': user}) 218 capabilities.update({'name': 'Juju GUI', 'tags': user})
220 driver = selenium.webdriver.Remote( 219 driver = selenium.webdriver.Remote(
221 desired_capabilities=capabilities, 220 desired_capabilities=capabilities,
222 command_executor=command_executor) 221 command_executor=command_executor)
223 cls.remote_driver = True 222 cls.remote_driver = True
224 details = 'https://saucelabs.com/jobs/' + driver.session_id 223 details = 'https://saucelabs.com/jobs/' + driver.session_id
225 printerr( 224 printerr(
226 '* Platform: {}'.format(get_platform(driver)), 225 '* Platform: {}'.format(get_platform(driver)),
227 '* Testcase: {}'.format(cls.__name__), 226 '* Testcase: {}'.format(cls.__name__),
228 '* Details: {}'.format(details), 227 '* Details: {}'.format(details),
229 sep='\n', 228 sep='\n',
230 ) 229 )
231 # Enable implicit waits for all browsers (DOM polling behavior) 230 # Enable implicit waits for all browsers (DOM polling behavior)
232 driver.implicitly_wait(20) 231 driver.implicitly_wait(20)
233 driver.set_script_timeout(30) 232 driver.set_script_timeout(30)
234 # We want to tell saucelabs when all the tests are done. 233 # We want to tell saucelabs when all the tests are done.
235 cls.app_url = os.environ['APP_URL'] 234 cls.app_url = os.environ.get('APP_URL', 'http://localhost:8888')
236 cls.driver = driver 235 cls.driver = driver
237 236
238 @classmethod 237 @classmethod
239 def tearDownClass(cls): 238 def tearDownClass(cls):
240 cls.driver.quit() 239 cls.driver.quit()
241 240
242 def run(self, result=None): 241 def run(self, result=None):
243 self.last_result = result 242 self.last_result = result
244 super(TestCase, self).run(result) 243 super(TestCase, self).run(result)
245 244
(...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after
431 printerr('\n- restarting API backend using juju ssh...') 430 printerr('\n- restarting API backend using juju ssh...')
432 juju('ssh', '-e', 'juju-gui-testing', 'juju-gui/0', 431 juju('ssh', '-e', 'juju-gui-testing', 'juju-gui/0',
433 'sudo', 'service', 'juju-api-improv', 'restart') 432 'sudo', 'service', 'juju-api-improv', 'restart')
434 self.load() 433 self.load()
435 self.handle_browser_warning() 434 self.handle_browser_warning()
436 self.wait_for_script( 435 self.wait_for_script(
437 'return app && app.env.get("connected");', 436 'return app && app.env.get("connected");',
438 error='Impossible to connect to the API backend after restart.', 437 error='Impossible to connect to the API backend after restart.',
439 timeout=30) 438 timeout=30)
440 printerr('- done') 439 printerr('- done')
OLDNEW

Powered by Google App Engine
RSS Feeds Recent Issues | This issue
This is Rietveld f62528b