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

Python - Gherkin Step conversion

I have a list with: (converted to a list after reading a .feature file) Given Device unit of measure is set to value "" And Device is set to value "Disabled" And Device is set to value "
vay
  • 65
  • 1
  • 7
0
votes
0 answers

Patterns for testing the step catalog in Python Behave

At my company our Behave step catalog is growing quite rapidly. It's becoming more and more clear that we need tests for the actual steps. E.g. that a certain given step set up data as it is expected to do. For a BDD framework like Behave it would…
Per Appelgren
  • 57
  • 1
  • 5
0
votes
2 answers

Cannot import behave.given in pydev for django

I have a Django project for which I am incorporating BDD using behave. I am using PyDev as my development environment. I have installed behave_dhango and behave using pip within the conda environment and I can see that the folders have been created…
0
votes
1 answer

Python behave step definitions not implemented

I am currently attempting to learn cucumber tests in Python with behave. Every time I have an error message that states my tests are undefined. Can anyone please tell me what I am doing wrong? my test.feature Feature: Python integration …
meowcat
  • 171
  • 1
  • 12
0
votes
1 answer

python 3 behave webdriver - OOP passing Driver

So I have been trying to make my project more OOP but am having great difficulty getting the driver to pass between the python files. TestAutomation/ Features/ somefeature.feature Objects/ main_misc.py Steps/ …
l3l00
  • 55
  • 1
  • 7
0
votes
0 answers

python module not found error even if module available

I am having below folder structure (find image) but when I use below code and run using command "behave -D BROWSER=chrome --no-capture " it gives me error like ModuleNotFoundError: No module named 'product_library' Not able to understand…
sushil
  • 301
  • 4
  • 16
0
votes
1 answer

Allure-behave not reporting failed suits as 'failed'

I have Python bdd tests in Behave. Using version 1.2.6 The issue I'm facing is that Allure-behave reports failed suits as "Passed", even if it does show a failed step, and report it as such. I have a behave.ini in my features folder…
Kotie Smit
  • 646
  • 1
  • 5
  • 18
0
votes
1 answer

Python Behave tests work and then stop working and then work without change

I have a simple feature where I am passing in 2 examples. Background: I create context params calls Given I create context params calls And I populate default array1 And I populate default array2 Scenario Outline: I enter x array and and…
0
votes
1 answer

Behave gherkin python pyautogui

Scenario: Navigate from overview to system details Given the login page is displyed When log in is selected the user selects a red bubble Then bubble-details are displayed @When('the user selects a red bubble') def…
0
votes
2 answers

JSON file isn't finished writing to by the time I load it, behave BDD

My program is writing to a JSON file, and then loading, reading, andPOSTing it. The writing part is being done by the behave BDD. # writing to the JSON file is done by behave data = json.load(open('results.json', 'r')) r =…
natn2323
  • 1,983
  • 1
  • 13
  • 30
0
votes
1 answer

Python..Behave..Selenium..Page Objects - Set up browser in environment.py but cannot access in page objects modules

My file structure is as follows Tests/ ├── BehaveTest1 │ ├── BehaveTest1.feature │ └── environment.py │ └── steps │ └── test_steps.py ├── BehaveTest2 │ ├── BehaveTest2.feature │ └── environment.py │ └── steps │ └──…
0
votes
2 answers

behave HOOK Error empty dict from behave.ini

I'm getting error HOOK-ERROR in before_all: KeyError: 'environment' when running behave from command line Project Structure: features/ * all feature files go here features/steps * all steps go here features/environment.py behave.ini (at the project…
Satish
  • 1,976
  • 1
  • 15
  • 19
0
votes
0 answers

Selenium (Docker, python, behave) takes hours to complete in CI

Tests are written with python behave and executed with Docker. Locally on Mac/Windows/Linux all 110 test steps complete under 4 minutes using the same sites whereas on CI agent (AWS) it takes 120-160 mins. Video showed that browser is spinning for…
0
votes
1 answer

Capture config error exception in python behave

I am running behave from python like this. from behave.__main__ import main as behave_main behave_main('path/to/feature_file.feature -f json -o /path/to/logs/here ) When there feature file path is missing it fails with error ConfigError: No steps…
0
votes
1 answer

Reusable Gherkin Steps

I'm doing a little PoC of system tests with python-behave. I wrote a couple of tests, but I wonder how to scale it: I have a few scenarios I wrote in Gherkin and implemented in python-behave, and I was wondering: In case there are many testers…
nerez
  • 437
  • 4
  • 18