def RunPage(self, page, tab, results): # When recording, sleep to catch any resources that load post-onload. tab.WaitForDocumentReadyStateToBeComplete() if self.test: dummy_results = page_measurement_results.PageMeasurementResults() dummy_results.WillMeasurePage(page) self.test.MeasurePage(page, tab, dummy_results) dummy_results.DidMeasurePage() else: # TODO(tonyg): This should probably monitor resource timing for activity # and sleep until 2s since the last network event with some timeout like # 20s. We could wrap this up as WaitForNetworkIdle() and share with the # speed index metric. time.sleep(3) # Run the actions for all measurements. Reload the page between # actions. should_reload = False interactive = self.options and self.options.interactive for action_name in self._action_names: if not hasattr(page, action_name): continue if should_reload: self.RunNavigateSteps(page, tab) action_runner = action_runner_module.ActionRunner(page, tab, self) if interactive: action_runner.RunAction(interact.InteractAction()) else: self._RunMethod(page, action_name, action_runner) should_reload = True
def RunPage(self, page, tab, results): interactive = self.options and self.options.interactive action_runner = action_runner_module.ActionRunner(page, tab, self) self.WillRunActions(page, tab) if interactive: action_runner.RunAction(interact.InteractAction()) else: self._RunMethod(page, self._action_name_to_run, action_runner) self.DidRunActions(page, tab) self._test_method(page, tab, results)
def GetCompoundActionFromPage(page, action_name, interactive=False): if interactive: return [interact.InteractAction()] if not action_name: return [] action_data_list = getattr(page, action_name) if not isinstance(action_data_list, list): action_data_list = [action_data_list] action_list = [] for subaction_data in action_data_list: for _ in xrange(subaction_data.get('repeat', 1)): action_list += GetSubactionFromData(page, subaction_data, interactive) return action_list
def GetCompoundActionFromPage(page, action_name, interactive=False): if interactive: return [interact.InteractAction()] if not action_name: return [] action_data_list = getattr(page, action_name) if not isinstance(action_data_list, list): action_data_list = [action_data_list] action_list = [] for subaction_data in action_data_list: subaction_name = subaction_data['action'] if hasattr(page, subaction_name): subaction = GetCompoundActionFromPage(page, subaction_name, interactive) else: subaction = [_GetActionFromData(subaction_data)] action_list += subaction * subaction_data.get('repeat', 1) return action_list