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

Skip Step Behave Python

Is there any option to skip step during an executing scenario in behave (Python). I have the following scenario: Scenario: Opening and closing driver by clicking and sliding When swipe right Then drawer should appear When swipe left …
0
votes
0 answers

Pass a variable from command line into scenario or feature in feature file

Currently I have Behave tests that run in Selenium but pick which browser to test based on an Environment Variable. Is there any way to pass text from the command line to a .feature file? Something like: DRIVER=chrome behave /path/to/features -i…
Cynic
  • 6,779
  • 2
  • 30
  • 49
0
votes
1 answer

Scenario outline title displays parameter name instead of its value in allure report

I have a next scenario outline: Scenario Outline: Create a user with role. Given select "" role Examples: roles | user_role | | admin | When I execute this scenario in IDE (PyCharm) I see parameter…
Den Silver
  • 199
  • 16
0
votes
0 answers

Unable to run Python/Behave test from prompt

I'm facing an import error when trying to run a behave .feature test from windows prompt: C:\MyProject\Features> behave Exception ImportError: No module named Pages.SamplePage Traceback (most recent call last): File…
0
votes
1 answer

Access Flask session in behave steps

I'm using Flask and behave, following the instructions here. I'm accessing pages using the Flask test client (rather than through a browser via something like Selenium). For example, calling get on the test client to get a response. I'd like to…
Sam
  • 5,997
  • 5
  • 46
  • 66
0
votes
3 answers

Behave in parallel

I try to run behave tests in parallel. For this I use behave-parallel lib and demo project https://github.com/vishalm/behave_parallel_demo. But OS is Windows 10. After steps from Read_me file. I am getting next…
Den Silver
  • 199
  • 16
0
votes
1 answer

How to create several implementation for the same named steps (behave)

I have two scenarios for two pages (homepage and property page). And in these scenarios I have the same steps (I fill in "field" with "text"). I need to implement one for homepage and one for property page. But behave sees only one implementation.…
0
votes
0 answers

How to include a made screenshot to json/html report

I use Bahave and there is a next condition for after_scenario in environment.py def after_scenario(context, scenario): if scenario.status == "failed": time_now = datetime.now().strftime("%Y-%m-%d_%H-%M-%S") …
0
votes
0 answers

Python-Behave Selenium - Get all child anchor text from parent element

I have the following header that I'm trying to get the multiple text from. I'm only able to get the text of menus Mobile App Guide, Quick Links, SDKs, Protocols & Plugins, and FAQ. But I'm not able to get the sub menu text. I'm using…
j7an
  • 104
  • 2
  • 11
0
votes
2 answers

How to import CSV as Table in Python Behave?

I have a feature file as blow. How could I import .csv file to replace Table in Examples? Scenario Outline: Blenders Given I put in a blender, when I switch the blender on then it should transform into Examples:…
0
votes
1 answer

Passing parameters between steps in behave

I have Scenario outline with multiple examples looking something like this: Examples: | country | type | number | | Poland | An individual | - | | Poland | Company | 8971660890 | | Germany …
Ewa
  • 65
  • 3
  • 11
0
votes
2 answers

How can i get current set of tags passed from behave command

I am new to Behave BDD. I want to go some logic based on the tags passed in command line. when I do context.tags/ context.scenario.tags I will get all the tags defined in the for that scenario. How can I get only the tags which are passed from the…
Shrikanth Kalluraya
  • 1,099
  • 1
  • 16
  • 34
0
votes
1 answer

Adding tag for examples in scenario outline (behave)

Is it possible to add tag for examples in scenario outline using behave? Something like this. Examples: |input |output | @test1 |one |two | @test2 |three |four | When I try to do this I get parser error:…
Ewa
  • 65
  • 3
  • 11
0
votes
0 answers

Can I tag step implementations in Behave?

I thought I read somewhere that step implementations could be tagged, and that tag would be inherited by any scenario consuming that step. I can no longer find any documentation in the API reference. Has anyone else seen or used that feature?
reuscam
  • 1,841
  • 2
  • 18
  • 23
0
votes
2 answers

Launch configuration first_behave.feature references non-existing project python_behave_template-master error

I configured Pydev in eclipse and also installed behave and cucumber to run a sample project in BDD approach. Each time i right click on the feature file (dirst_behave.feature) and Run as "Cucumber feature", i get the error - "Launch configuration…
pradeep
  • 27
  • 5