How to use execute_after_scenario_steps method in toolium

Best Python code snippet using toolium_python

driver_wrappers_pool.py

Source:driver_wrappers_pool.py Github

copy

Full Screen

...114 if not test_passed:115 cls.capture_screenshots(test_name)116 # Execute behave dynamic environment117 if context and hasattr(context, 'dyn_env'):118 context.dyn_env.execute_after_scenario_steps(context)119 # Save webdriver logs on error or if it is enabled120 cls.save_all_webdriver_logs(test_name, test_passed)121 elif scope == 'session':122 from toolium.visual_test import VisualTest123 VisualTest.update_latest_report()124 # Close browser and stop driver if it must not be reused125 reuse_driver = cls.get_default_wrapper().should_reuse_driver(scope, test_passed, context)126 cls.stop_drivers(reuse_driver)127 cls.download_videos(test_name, test_passed, reuse_driver)128 cls.save_all_ggr_logs(test_name, test_passed)129 cls.remove_drivers(reuse_driver)130 @classmethod131 def stop_drivers(cls, maintain_default=False):132 """Stop all drivers except default if it should be reused...

Full Screen

Full Screen

env_utils.py

Source:env_utils.py Github

copy

Full Screen

...88 # ---- actions before each scenario ----89 context.dyn_env.execute_before_scenario_steps(context)90 def after_scenario(context, scenario):91 # ---- actions after each scenario ----92 context.dyn_env.execute_after_scenario_steps(context)93 def after_feature(context, feature):94 # ---- actions after feature ----95 context.dyn_env.execute_after_feature_steps(context)96 """97 def __init__(self, **kwargs):98 """99 constructor100 :param kwargs: parameters set101 :param logger: logger instance102 :param show: determine if messages are displayed by console103 """104 logger_class = kwargs.get("logger", None)105 self.show = kwargs.get("show", True)106 self.logger = Logger(logger_class, self.show)107 self.init_actions()108 self.scenario_counter = 0109 self.feature_error = False110 self.scenario_error = False111 def init_actions(self):112 """clear actions lists"""113 self.actions = {ACTIONS_BEFORE_FEATURE: [],114 ACTIONS_BEFORE_SCENARIO: [],115 ACTIONS_AFTER_SCENARIO: [],116 ACTIONS_AFTER_FEATURE: []}117 def get_steps_from_feature_description(self, description):118 """119 get all steps defined in the feature description associated to each action120 :param description: feature description121 """122 self.init_actions()123 label_exists = EMPTY124 step_text_start = False125 for row in description:126 if label_exists != EMPTY:127 # in case of a line with a comment, it is removed128 if "#" in row:129 row = row[0:row.find("#")].strip()130 if any(row.startswith(x) for x in KEYWORDS):131 self.actions[label_exists].append(row)132 elif row.strip()[-3:] in STEP_TEXT_SEPARATORS and step_text_start:133 self.actions[label_exists][-1] = "%s\n %s" % (self.actions[label_exists][-1], row)134 step_text_start = False135 elif row.find(TABLE_SEPARATOR) >= 0 or step_text_start:136 self.actions[label_exists][-1] = "%s\n %s" % (self.actions[label_exists][-1], row)137 elif row.strip()[:3] in STEP_TEXT_SEPARATORS and not step_text_start:138 self.actions[label_exists][-1] = "%s\n %s" % (self.actions[label_exists][-1], row)139 step_text_start = True140 else:141 label_exists = EMPTY142 for action_label in self.actions:143 if row.lower().find(action_label) >= 0:144 label_exists = action_label145 def __remove_prefix(self, step):146 """147 remove the step prefix to will be replaced by Given148 :param step: step text149 """150 step_length = len(step)151 for k in KEYWORDS:152 step = step.lstrip(k)153 if len(step) < step_length:154 break155 return step156 def __print_step_by_console(self, step):157 """158 print the step by console if the show variable is enabled159 :param step: step text160 """161 step_list = step.split('\n')162 for s in step_list:163 self.logger.by_console(' %s' % repr(s).replace("u'", "").replace("'", ""))164 def __execute_steps_by_action(self, context, action):165 """166 execute a steps set by action167 :param context: It’s a clever place where you and behave can store information to share around,168 automatically managed by behave.169 :param action: action executed: see labels allowed above.170 """171 if len(self.actions[action]) > 0:172 if action == ACTIONS_BEFORE_SCENARIO:173 self.logger.by_console('\n')174 self.scenario_counter += 1175 self.logger.by_console(176 " ------------------ Scenario Nº: %d ------------------" % self.scenario_counter)177 self.logger.by_console(' %s:' % action)178 elif action in [ACTIONS_BEFORE_FEATURE, ACTIONS_AFTER_FEATURE]:179 self.logger.by_console('\n')180 for item in self.actions[action]:181 self.scenario_error = False182 try:183 self.__print_step_by_console(item)184 context.execute_steps('''%s%s''' % (GIVEN_PREFIX, self.__remove_prefix(item)))185 self.logger.debug('step defined in pre-actions: %s' % repr(item))186 except Exception as exc:187 self.feature_error = action in [ACTIONS_BEFORE_FEATURE]188 self.scenario_error = action in [ACTIONS_BEFORE_SCENARIO]189 self.logger.error(exc)190 self.error_exception = exc191 break192 def reset_error_status(self):193 """194 Check if the dyn_env has got any exception when executing the steps and restore the value of status to False.195 :return: True if any exception has been raised when executing steps196 """197 try:198 return self.feature_error or self.scenario_error199 finally:200 self.feature_error = False201 self.scenario_error = False202 def execute_before_feature_steps(self, context):203 """204 actions before the feature205 :param context: It’s a clever place where you and behave can store information to share around,206 automatically managed by behave.207 """208 self.__execute_steps_by_action(context, ACTIONS_BEFORE_FEATURE)209 if context.dyn_env.feature_error:210 # Mark this Feature as skipped. Steps will not be executed.211 context.feature.mark_skipped()212 def execute_before_scenario_steps(self, context):213 """214 actions before each scenario215 :param context: It’s a clever place where you and behave can store information to share around,216 automatically managed by behave.217 """218 if not self.feature_error:219 self.__execute_steps_by_action(context, ACTIONS_BEFORE_SCENARIO)220 if context.dyn_env.scenario_error:221 # Mark this Scenario as skipped. Steps will not be executed.222 context.scenario.mark_skipped()223 def execute_after_scenario_steps(self, context):224 """225 actions after each scenario226 :param context: It’s a clever place where you and behave can store information to share around,227 automatically managed by behave.228 """229 if not self.feature_error:230 self.__execute_steps_by_action(context, ACTIONS_AFTER_SCENARIO)231 # Behave dynamic environment: Fail all steps if dyn_env has got any error and reset it232 if self.reset_error_status():233 context.scenario.reset()234 context.dyn_env.fail_first_step_precondition_exception(context.scenario)235 def execute_after_feature_steps(self, context):236 """237 actions after the feature...

Full Screen

Full Screen

driver_manager.py

Source:driver_manager.py Github

copy

Full Screen

...54 if scope == 'function':55 if not test_passed:56 cls.capture_screenshots(test_name)57 if context and hasattr(context, 'dyn_env'):58 context.pytalos.dyn_env.execute_after_scenario_steps(context)59 cls.save_all_webdriver_logs(test_name, test_passed)60 reuse_driver = cls.get_default_wrapper().should_reuse_driver(scope, test_passed, context)61 cls.stop_drivers(reuse_driver)62 cls.download_videos(test_name, test_passed, reuse_driver)63 cls.save_all_ggr_logs(test_name, test_passed)64 cls.remove_drivers(reuse_driver)65 @classmethod66 def stop_drivers(cls, maintain_default=False):67 driver_wrappers = cls.driver_wrappers[1:] if maintain_default else cls.driver_wrappers68 close_driver = settings.settings.PYTALOS_RUN['close_webdriver']69 for driver_wrapper in driver_wrappers:70 if not driver_wrapper.driver:71 continue72 try:...

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run toolium automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful