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

Javascript box not being triggered in selenium

I'm currently trying to automate part of our web application, mainly a form of @mentioning similar to facebook. In the front end when a user types @ into a text input the API calls the list of users and displays them in a box that appears. This…
0
votes
2 answers

Put custom methods in Behave's environment.py

I am attempting to put the custom method, that would send results of automated tests to JIRA, in the Behave's environment.py. It would be in after_scenario() or after_feature(). So I want it to send the results to JIRA after closing tests. It seems…
0
votes
2 answers

How to handle the situation when the Gherkin step parameter itself has a string which is a part of the step

I am facing a problem where python behave is parsing a step definition weird when one of my parameter I am passing is a part of the step sentence itself. Here is the step definition @when(u'I set the value of {setting} to {value} in…
0
votes
1 answer

Behave framework .ini file usage

In my .ini file I have [behave] format=rerun outfiles=rerun_failing.features So I want to use "rerun_failing.features" file for storing scenarios that fail. However when I run '--steps-catalog' command, it also stores that catalog to the same file.…
0
votes
1 answer

How can I pass a variable from the Python-Behave step?

Basically I wrote a step called @When("I go to {url}") Then I called it from the feature file using When I go to http://youtube.com and it worked But I want to call it using When I go to YouTube Same would happen with css selectors (For Then logo is…
Franco Roura
  • 807
  • 8
  • 26
0
votes
3 answers

Naming Cucumber's Data Table

I am creating test cases on forms that could contains over 50 parameters, some of them would show up when a certain set of questions would be answered specifically. The data tables were getting very long so I broke them into multiple data tables,…
0
votes
2 answers

Move the headings from top of Cucumber's Data Table to side - Python

I am looking for the ways to change the headings of Cucumber's Data Table to the side. So it will make the feature file readable. Ordinary way: | Name | Email | Phone No. | ......... | | John | i@g.net | 098765644 | ......... | It can be a very…
0
votes
1 answer

Move Gherkin's (i.e. Cucumber and Behave) Data Table to JSON

I was using Behave and Selenium to test on something that use a large amount of data. Data tables were becoming too big and making the Gherkin documentation unreadable. I would like to move most of the data from data tables to external file such as…
0
votes
2 answers

Running feature files python behave - Pyhcharm - No Feature found

I'm having a problem running one of my feature files. I can run one of them but not the other. I have the exact same setup for run configurations for both. raise ParserError(msg, None, self.filename) behave.parser.ParserError: Failed to parse…
Sam
  • 1,207
  • 4
  • 26
  • 50
0
votes
2 answers

How to call a scenario from other scenario present in separate feature files? i.e. Feature1.feature Scenario1 Feature2>>scenario2

In Behave, for python How to call a scenario from other scenarios present in separate feature files? i.e. In Feature1.feature file Scenario1 Feature2.scenario2 Feature3.scenario3
Shalini
  • 23
  • 3
0
votes
1 answer

How to pass dictionary or list or custom objects from feature file

If a method takes dictionary as parameter, how to pass it. Do we need to construct the dictionary from values present in feature file and pass internally to the method. Is there any direct way we can pass objects?
bhasker
  • 645
  • 1
  • 7
  • 20
0
votes
0 answers

python-behave: How can I show all print() statements on command line?

Part of my test is to print some statements in command line. I followed steps which mentioned here: How can I see print() statements in behave (BDD) However, I’m not able to see the print() statement from last line of my code. I ran…
Raja David
  • 304
  • 7
  • 16
0
votes
1 answer

Why is ActiveTagMatcher is ignoring some of the values I'm passing to it?

I've been successfully using ActiveTagMatcher to tag some tests that should be run under some conditions, but for some reason ActiveTagMatcher is ignoring some of the values I set. I've boiled it down to this example: features/test.feature: Feature:…
Louis
  • 146,715
  • 28
  • 274
  • 320
0
votes
1 answer

How to skip steps in background of Behave BDD?

I'm using Python & Behave BDD for automation. As I know, background runs before each scenario, but I need background to run before scenarios only with @need_background tag. How can I achieve this? I have tried to get current scenario tag and if tag…
hudrogen
  • 342
  • 1
  • 3
  • 13
0
votes
1 answer

How to put things together in Python-Behave and Selenium Page Object Model

I found a boilerplate on github and wanted to integrate a POM design to my BDD framework with Python-Behave and Selenium. My Python is not good, and i get this error: AttributeError: 'Context' object has no attribute 'get' class Page(object): …
teddybear123
  • 2,314
  • 6
  • 24
  • 38