@before.harvest
def initial_setup(server):
 world.absorb(settings.LETTUCE_SELENIUM_CLIENT, 'LETTUCE_SELENIUM_CLIENT')
 if (world.LETTUCE_SELENIUM_CLIENT == 'local'):
  browser_driver = getattr(settings, 'LETTUCE_BROWSER', 'chrome')
  if (browser_driver == 'chrome'):
   desired_capabilities = DesiredCapabilities.CHROME
   desired_capabilities['loggingPrefs'] = {'browser': 'ALL'}
  else:
   desired_capabilities = {}
  success = False
  num_attempts = 0
  while ((not success) and (num_attempts < MAX_VALID_BROWSER_ATTEMPTS)):
   try:
    if (browser_driver == 'firefox'):
     world.browser = Browser(browser_driver)
    else:
     world.browser = Browser(browser_driver, desired_capabilities=desired_capabilities)
    world.browser.driver.set_script_timeout(GLOBAL_SCRIPT_TIMEOUT)
    world.visit('/')
   except WebDriverException:
    LOGGER.warn('Error acquiring %s browser, retrying', browser_driver, exc_info=True)
    if hasattr(world, 'browser'):
     world.browser.quit()
    num_attempts += 1
   else:
    success = True
  if (not success):
   raise IOError('Could not acquire valid {driver} browser session.'.format(driver=browser_driver))
  world.absorb(0, 'IMPLICIT_WAIT')
  world.browser.driver.set_window_size(1280, 1024)
 elif (world.LETTUCE_SELENIUM_CLIENT == 'saucelabs'):
  config = get_saucelabs_username_and_key()
  world.browser = Browser('remote', url='http://{}:{}@ondemand.saucelabs.com:80/wd/hub'.format(config['username'], config['access-key']), **make_saucelabs_desired_capabilities())
  world.absorb(30, 'IMPLICIT_WAIT')
  world.browser.set_script_timeout(GLOBAL_SCRIPT_TIMEOUT)
 elif (world.LETTUCE_SELENIUM_CLIENT == 'grid'):
  world.browser = Browser('remote', url=settings.SELENIUM_GRID.get('URL'), browser=settings.SELENIUM_GRID.get('BROWSER'))
  world.absorb(30, 'IMPLICIT_WAIT')
  world.browser.driver.set_script_timeout(GLOBAL_SCRIPT_TIMEOUT)
 else:
  raise Exception("Unknown selenium client '{}'".format(world.LETTUCE_SELENIUM_CLIENT))
 world.browser.driver.implicitly_wait(world.IMPLICIT_WAIT)
 world.absorb(world.browser.driver.session_id, 'jobid')

@ before . harvest def initial_setup ( server ) : world . absorb ( settings . LETTUCE_SELENIUM_CLIENT , 'LETTUCE_SELENIUM_CLIENT' ) if ( world . LETTUCE_SELENIUM_CLIENT == 'local' ) : browser_driver = getattr ( settings , 'LETTUCE_BROWSER' , 'chrome' ) if ( browser_driver == 'chrome' ) : desired_capabilities = DesiredCapabilities . CHROME desired_capabilities [ 'loggingPrefs' ] = { 'browser' : 'ALL' } else : desired_capabilities = { } success = False num_attempts = 0 while ( ( not success ) and ( num_attempts < MAX_VALID_BROWSER_ATTEMPTS ) ) : try : if ( browser_driver == 'firefox' ) : world . browser = Browser ( browser_driver ) else : world . browser = Browser ( browser_driver , desired_capabilities = desired_capabilities ) world . browser . driver . set_script_timeout ( GLOBAL_SCRIPT_TIMEOUT ) world . visit ( '/' ) except WebDriverException : LOGGER . warn ( 'Error acquiring %s browser, retrying' , browser_driver , exc_info = True ) if hasattr ( world , 'browser' ) : world . browser . quit ( ) num_attempts += 1 else : success = True if ( not success ) : raise IOError ( 'Could not acquire valid {driver} browser session.' . format ( driver = browser_driver ) ) world . absorb ( 0 , 'IMPLICIT_WAIT' ) world . browser . driver . set_window_size ( 1280 , 1024 ) elif ( world . LETTUCE_SELENIUM_CLIENT == 'saucelabs' ) : config = get_saucelabs_username_and_key ( ) world . browser = Browser ( 'remote' , url = 'http://{}:{}@ondemand.saucelabs.com:80/wd/hub' . format ( config [ 'username' ] , config [ 'access-key' ] ) , ** make_saucelabs_desired_capabilities ( ) ) world . absorb ( 30 , 'IMPLICIT_WAIT' ) world . browser . set_script_timeout ( GLOBAL_SCRIPT_TIMEOUT ) elif ( world . LETTUCE_SELENIUM_CLIENT == 'grid' ) : world . browser = Browser ( 'remote' , url = settings . SELENIUM_GRID . get ( 'URL' ) , browser = settings . SELENIUM_GRID . get ( 'BROWSER' ) ) world . absorb ( 30 , 'IMPLICIT_WAIT' ) world . browser . driver . set_script_timeout ( GLOBAL_SCRIPT_TIMEOUT ) else : raise Exception ( "Unknown selenium client '{}'" . format ( world . LETTUCE_SELENIUM_CLIENT ) ) world . browser . driver . implicitly_wait ( world . IMPLICIT_WAIT ) world . absorb ( world . browser . driver . session_id , 'jobid' )
initial setup for the daemon .