Best Python code snippet using gherkin-python
compiler.py
Source: compiler.py
...22 if len(scenario['steps']) > 0:23 steps.extend(background_steps)24 tags = list(feature_tags) + list(scenario['tags'])25 for step in scenario['steps']:26 steps.append(_pickle_step(step))27 pickle = {28 'tags': _pickle_tags(tags),29 'name': scenario['name'],30 'language': language,31 'locations': [_pickle_location(scenario['location'])],32 'steps': steps33 }34 pickles.append(pickle)35def _compile_scenario_outline(feature_tags, background_steps, scenario_outline, language, pickles):36 for examples in (e for e in scenario_outline['examples'] if 'tableHeader' in e):37 variable_cells = examples['tableHeader']['cells']38 for values in examples['tableBody']:39 value_cells = values['cells']40 steps = list()41 if len(scenario_outline['steps']) > 0:42 steps.extend(background_steps)43 tags = list(feature_tags) \44 + list(scenario_outline['tags']) \45 + list(examples['tags'])46 for scenario_outline_step in scenario_outline['steps']:47 step_text = _interpolate(48 scenario_outline_step['text'],49 variable_cells,50 value_cells)51 arguments = _create_pickle_arguments(52 scenario_outline_step.get('argument'),53 variable_cells,54 value_cells)55 _pickle_step = {56 'text': step_text,57 'arguments': arguments,58 'locations': [59 _pickle_location(values['location']),60 _pickle_step_location(scenario_outline_step)61 ]62 }63 steps.append(_pickle_step)64 pickle = {65 'name': _interpolate(66 scenario_outline['name'],67 variable_cells,68 value_cells),69 'language': language,70 'steps': steps,71 'tags': _pickle_tags(tags),72 'locations': [73 _pickle_location(values['location']),74 _pickle_location(scenario_outline['location'])75 ]76 }77 pickles.append(pickle)78def _create_pickle_arguments(argument, variables, values):79 result = []80 if not argument:81 return result82 if argument['type'] == 'DataTable':83 table = {'rows': []}84 for row in argument['rows']:85 cells = [86 {87 'location': _pickle_location(cell['location']),88 'value': _interpolate(cell['value'], variables, values)89 } for cell in row['cells']90 ]91 table['rows'].append({'cells': cells})92 result.append(table)93 elif argument['type'] == 'DocString':94 docstring = {95 'location': _pickle_location(argument['location']),96 'content': _interpolate(argument['content'], variables, values)97 }98 if 'contentType' in argument:99 docstring['contentType'] = _interpolate(argument['contentType'], variables, values)100 result.append(docstring)101 else:102 raise Exception('Internal error')103 return result104def _interpolate(name, variable_cells, value_cells):105 for n, variable_cell in enumerate(variable_cells):106 value_cell = value_cells[n]107 name = re.sub(108 u'<{0[value]}>'.format(variable_cell),109 value_cell['value'],110 name111 )112 return name113def _pickle_steps(scenario_definition):114 return [_pickle_step(step)115 for step in scenario_definition['steps']]116def _pickle_step(step):117 return {118 'text': step['text'],119 'arguments': _create_pickle_arguments(120 step.get('argument'),121 [],122 []),123 'locations': [_pickle_step_location(step)]124 }125def _pickle_step_location(step):126 return {127 'line': step['location']['line'],128 'column': step['location']['column'] + count_symbols(step.get('keyword', 0))129 }130def _pickle_location(location):...
Check out the latest blogs from LambdaTest on this topic:
Agile project management is a great alternative to traditional methods, to address the customer’s needs and the delivery of business value from the beginning of the project. This blog describes the main benefits of Agile for both the customer and the business.
In an ideal world, you can test your web application in the same test environment and return the same results every time. The reality can be difficult sometimes when you have flaky tests, which may be due to the complexity of the web elements you are trying to perform an action on your test case.
Ever since the Internet was invented, web developers have searched for the most efficient ways to display content on web browsers.
So, now that the first installment of this two fold article has been published (hence you might have an idea of what Agile Testing is not in my opinion), I’ve started feeling the pressure to explain what Agile Testing actually means to me.
Have you ever struggled with handling hidden elements while automating a web or mobile application? I was recently automating an eCommerce application. I struggled with handling hidden elements on the web page.
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.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!