How to use get_steps_from_feature_description method in toolium

Best Python code snippet using toolium_python

environment.py

Source:environment.py Github

copy

Full Screen

...52 os.makedirs(name)53 __logger__.info("log folder has been created with name: %s" % name)54 except Exception, e:55 assert False, "ERROR - creating logs folder \n - %s" % str(e)56def get_steps_from_feature_description(label, feature):57 """58 return all steps defined in feature description associated to label59 :param label: labels allowed:60 - Actions Before the Feature61 - Actions Before each Scenario62 - Actions After each Scenario63 - Actions After the Feature64 :param feature: feature values65 :return: list66 Hint: must be ":" in the step prefix (used as separator). ex: "Setup: "67 """68 steps_list = []69 label_exists = False70 for description in feature.description:71 if label_exists:72 if description.split(SEPARATOR)[0] in KEYWORDS:73 steps_list.append(description.replace(description.split(SEPARATOR)[0] + SEPARATOR, GIVEN_PREFIX))74 else:75 break76 if description.lower().find(label) >= 0:77 label_exists = True78 return steps_list79def replace_given_to_add(value):80 """81 replacing Given prefix to Add prefix82 :param value: text to verify83 :return: string84 """85 return value.replace(GIVEN_PREFIX, AND_PREFIX)86def execute_one_step(context, name, **kwargs):87 """88 execute a step manually89 :param name: step name90 :param show: determine if the steps is displayed or not (the "Given" label is replaced to "And" label)91 """92 show = kwargs.get("show", False)93 __logger__.debug("step defined in pre-actions: %s" % name)94 if show:95 print colored(' %s' % replace_given_to_add(name), 'green')96 context.execute_steps(name)97def init_feature():98 """99 features_data, scenarios_status dicts are initialized100 """101 global features_data, scenarios_status102 features_data = {"scenario_status": None, "file_name": ""}103 scenarios_status = {"untested": 0, "skipped": 0, "passed": 0, "failed": 0}104def process_scenario(scenario):105 """106 determine the status in each scenario107 :param scenario: scenario unique108 """109 scenarios_status[scenario.status or 'skipped'] += 1110def process_scenario_outline(scenario_outline):111 """112 determine the scenario status in each outline example113 :param scenario_outline: is executed for each row in the Examples section114 """115 for scenario in scenario_outline.scenarios:116 process_scenario(scenario)117def before_all(context):118 """119 actions before all120 :param context: It’s a clever place where you and behave can store information to share around. It runs at three levels, automatically managed by behave.121 """122 __create_log_folder("logs")123 context.config.setup_logging(configfile="logging.ini")124def after_all(context):125 """126 actions after all127 :param context: It’s a clever place where you and behave can store information to share around. It runs at three levels, automatically managed by behave.128 """129 if SHOW_SUMMARY:130 summary_color = u'yellow'131 print colored(" SUMMARY:", summary_color)132 print colored("-------------------------------------------------", summary_color)133 for item in features_list:134 status = item["scenario_status"]135 print colored(" - %s >> passed: %s, failed: %s, skipped: %s and total: %s with duration: %.3f seconds."136 % (item["file_name"], status["passed"], status["failed"], status["skipped"], str(item["total"]),137 item["duration"]), summary_color)138 print colored("-------------------------------------------------", summary_color)139def before_feature(context, feature):140 """141 actions before each feature142 in case of backgroundFeature, re-throw steps defined in the feature descriptions143 :param context: It’s a clever place where you and behave can store information to share around. It runs at three levels, automatically managed by behave.144 """145 global steps_after_feature, steps_before_scenario, steps_after_scenario146 __logger__.info("\n\n\n\n")147 __logger__.info(">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>")148 __logger__.info(">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>")149 __logger__.info("FEATURE name: %s" % feature)150 __logger__.info("FEATURE description: %s" % feature.description)151 # ---- ConditionsBeforeFeature ----152 steps_before_feature = get_steps_from_feature_description(ACTIONS_BEFORE_FEATURE, feature)153 for item in steps_before_feature:154 execute_one_step(context, item)155 steps_after_feature = get_steps_from_feature_description(ACTIONS_AFTER_FEATURE, feature)156 steps_before_scenario = get_steps_from_feature_description(ACTIONS_BEFORE_SCENARIO, feature)157 steps_after_scenario = get_steps_from_feature_description(ACTIONS_AFTER_SCENARIO, feature)158def after_feature(context, feature):159 """160 actions executed after each feature161 :param context: It’s a clever place where you and behave can store information to share around. It runs at three levels, automatically managed by behave.162 :param feature: feature properties163 """164 global steps_after_feature165 # ---- ConditionsAfterFeature ----166 for item in steps_after_feature:167 execute_one_step(context, item, show=True)168 # ---- Summary ----169 features_data["file_name"] = feature.filename170 features_data["scenario_status"] = scenarios_status171 features_data["duration"] = feature.duration...

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