def get_path_for_metadata(): path = config.utils.get('metadata_path', None) if path is None: log.info("No 'metadata_path' provided in config. " "Defaulting to '.test_metadata'") path = '.test_metadata' path = path.rstrip(os.path.sep) return path
def run_multiple_times(self): for i in range(1, self.run_count + 1): log.info('Benchmark \'{}\' iter {}'.format(self._testMethodName, i)) try: self._set_up_iter() res = self._single_method() self._tear_down_iter() except: log.exception('Benchmark \'{}\' iter {} exception:'.format(self._testMethodName, i)) raise return res
def _start_driver(cls, desired_capabilities, command_executor): """ :raise: ConnectionError """ try: log.info("starting session...") driver = cls.driver_class( command_executor=command_executor, desired_capabilities=desired_capabilities) return driver except URLError: raise ConnectionError(command_executor)
def _start_driver(cls, desired_capabilities, command_executor): """ :raise: ConnectionError """ try: log.info('starting session...') driver = cls.driver_class( command_executor=command_executor, desired_capabilities=desired_capabilities) return driver except URLError: raise ConnectionError(command_executor)
def _setup_test(self): if not config.session['shared']: self.driver = self._create_session(self) self.driver._testMethodName = self._testMethodName log.info('sessionId: %s', self.driver.session_id) log.info('capabilities: %s' % self.driver.capabilities) if config.utils.get('collect_logcat', True): self.logcat = logcat.Logcat(self.driver) if config.utils.get('record_screencast') and config.utils.get('record_screencast_autostart', True): screencast.start_screencast_recorder()
def run_multiple_times(self): for i in range(1, self.run_count + 1): log.info('Benchmark \'{}\' iter {}'.format(self._testMethodName, i)) try: self._set_up_iter() res = self._single_method() self._tear_down_iter() except: log.exception('Benchmark \'{}\' iter {} exception:'.format( self._testMethodName, i)) raise return res
def _try_make_screenshot(): path = config.utils.get('screenshots_path', None) if path is None: log.info("No 'screenshot_path' provided in config. Defaulting to 'screenshots'") path = 'screenshots' driver = getattr(current_test, 'driver', None) if driver is None: log.info("%s has no driver object. Aborting taking error screenshot." % str(current_test)) return path = path.rstrip(os.path.sep) try: _make_screenshot(driver, path) except Exception as e: log.warning("Unexpected exception %s occurred while trying to save screenshot", e)
def _try_make_screenshot(): path = config.utils.get('screenshots_path', None) if path is None: log.info( "No 'screenshot_path' provided in config. Defaulting to 'screenshots'" ) path = 'screenshots' driver = getattr(current_test, 'driver', None) if driver is None: log.info("%s has no driver object. Aborting taking error screenshot." % str(current_test)) return path = path.rstrip(os.path.sep) try: _make_screenshot(driver, path) except Exception as e: log.warning( "Unexpected exception %s occurred while trying to save screenshot", e)
def _load(self): log.info("Loading %s" % self.__title__) if self._on_load_hooks: log.info("Running onload hooks") for hook in self._on_load_hooks: hook() if self._on_load_elements: log.info("Checking onload elements") for locator in self._on_load_elements: try: element = find_element(self.driver, locator) wait = waiter(element) wait.until(lambda el: el.is_displayed(), "Element %s is still not displayed" % locator["value"]) except: raise Exception("Failed to load page: %s\n" "%s\n" % (self.__title__, format_exc())) log.info("%s loaded" % self.__title__)
def _load(self): log.info("Loading %s" % self.__title__) if self._on_load_hooks: log.info("Running onload hooks") for hook in self._on_load_hooks: hook() if self._on_load_elements: log.info("Checking onload elements") for locator in self._on_load_elements: try: element = find_element(self.driver, locator) wait = waiter(element) wait.until( lambda el: el.is_displayed(), "Element %s is still not displayed" % locator["value"]) except: raise Exception("Failed to load page: %s\n" "%s\n" % (self.__title__, format_exc())) log.info("%s loaded" % self.__title__)
def page_loaded(self): pl = self.execute_script('return document.readyState;') log.info("Status Page Loaded: %s" % pl) return pl == 'complete'
def _setup_test(self): if not config.session["shared"]: self.driver = self._create_session(self) self.driver._testMethodName = self._testMethodName log.info("sessionId: %s", self.driver.session_id) log.info("capabilities: %s" % self.driver.capabilities)