Questions tagged [python-behave]

Behave is a BDD framework for Python, based on the Cucumber Framework.

Behave is Behaviour Driven Development (BDD) framework for Python. It follows the Gherkin syntax, which defines Scenarios and steps files.

A scenario is a human readable flow, for example:

Scenario: Calling the metadata API
   Given A matching server
   When I call metadata
   Then metadata response is JSON
   And response status code is 200

The steps file casts programmatic meaning to each line, for example:

...
@then('response status code is {expected_status_code}')
def step_impl(context, expected_status_code):
    assert_equals(context.response.status_code, int(expected_status_code))

@then('metadata response is JSON')
def step_impl(context):
    json.loads(context.metadata_response.data)
...

Behave combines the scenario and steps to a test report:

enter image description here

521 questions
0
votes
1 answer

How can I get helpful errors when undefined steps?

My behave steps are more or less groups with variations. I would like to be able to give suggestions. example: @given('a cookie with sprinkles') def cookie_with_sprinkles(): """Given a cookie with sprinkles""" ... @given('a cookie with…
Mary Bergman
  • 98
  • 1
  • 5
0
votes
1 answer

**Python Selenium Behave** Alert box automatically closes after going to next step

I am in a project in which I am making a modular behavior driven framework for the company I am working right now. In making a modular approach of the step "user accepts alert", when I test it and came an expected alert box, it automatically closes…
0
votes
1 answer

Chrome driver failing when using Behave

I'm starting to look at Behave to use for BDD, but I've hit a problem. I have a quite few Selenium (Python) tests that I'm already running successfully, but as soon as I use behave I get an error "chromedriver.exe has stopped working". In my…
ChrisG29
  • 1,501
  • 3
  • 25
  • 45
0
votes
1 answer

Generate data for behave tables in runtime

I have a behave test where I would like to have part of the data inside a behave table to be generated after a step has executed. E.g. Given I have a step When I executed some other step Then the message should have the following data | field |…
nnja
  • 325
  • 3
  • 15
0
votes
1 answer

Behaviour Driven Development - Undefined steps in Behave using Python with Flask

I'm following a Flask tutorial and currently looking at Behaviour Driven Development using Behave. My task is to build a very basic blog application that allows a single user to log in, log out and create blog posts, using BDD. I've written the…
James
  • 11
  • 6
0
votes
1 answer

python behave generates XML that is "Not well-formed"

I am using python behave for about 40 tests that I run. Now I am trying to make a more-or-less decent looking HTML report for myself and my client. I run the tests via commandline: behave --junit. Next I take the xml, parse it (elementtree) and…
Chai
  • 1,796
  • 2
  • 18
  • 31
0
votes
1 answer

how to import module only once in python behave step files

I am very new to Python and Behave. In my step file, test_steps.py, I have imported the following: from behave import given, when, then, step from behave_http.steps import * from datetime import datetime import time import pdb import…
Claire
  • 23
  • 5
0
votes
2 answers

Dynamic scenario dispatcher for Python Behave

I am running multiple scenarios and would like to incorporate some sort of dynamic scenario dispatcher which would allow me to have specific steps to execute after a test is done based on the scenario executed. When I was using PHPUnit, I used to be…
nnja
  • 325
  • 3
  • 15
0
votes
1 answer

python- behave: generate step functionality throws list index out of range

this is my first question here, so any tips on improvement on that are welcome :) I am figuring out how to write tests using: Sublime Text 3, python, and behave. What works now is that my feature file is recognised: has all the right colours, as far…
Chai
  • 1,796
  • 2
  • 18
  • 31
0
votes
1 answer

How can I specify the type of a column in a python behave step data table?

Assume I have a step defined as follows: Then I would expect to see the following distribution for Ford | engine | doors | color | | 2.1L | 4 | red | And I have the step implementation that reads the table and does the assert…
Baire
  • 45
  • 9
0
votes
1 answer

Python trying to run behave get errors

I'm trying to use behave to run selenium tests but I'm stuck at start of that idea. I've setup python, selenium and behave as it should be. I'm running python scripts with selenium without an problem. My problems starts when I try to run them with…
0
votes
5 answers

How to call a scenario several times without tableized items in a behave test?

I 'd like to call the scenario -Let's say 500 times- in Gherkin test without tableized items. The reason is I 'd like to use randomized variables instead of written by myself. I know how to implement random functionality to the tests but it is…
allworldfree
  • 55
  • 1
  • 2
  • 7
0
votes
0 answers

How do I make behave smoke to try the last failed scenario first?

py.test has a wonderful feature called --failed-first which tells it to run the tests that failed last time before the others. This speeds up the execution process considerably. I am looking for something similar for behave smoke. Is there way to…
sorin
  • 161,544
  • 178
  • 535
  • 806
0
votes
1 answer

Read current step string on behave

I'd like to read the current step string that is matched. In behave, once the match is done, it runs the function that is tagged with the matching step string. I'd like to print this step string. How would I be able to do such a simple…
nnja
  • 325
  • 3
  • 15
0
votes
1 answer

Python Behave + non-ascii steps on Windows

Python BDD framework Behave has the following code in its runner.py with open(filename) as f: # -- FIX issue #80: exec(f.read(), globals, locals) # try: filename2 = os.path.relpath(filename, os.getcwd()) code = compile(f.read(),…
user996142
  • 2,753
  • 3
  • 29
  • 48