Complete first behave step definition

Pre-Requisites:

Continue from the previous page where we wrote the behave scenario

Steps:

1. Right Click on the steps folder and create new – python files (Alternately, you can also just select File and create “first_behave.py”)

behave_first_step_file

2. If you imported the python_behave_template, the file “first_behave.py” is already present, so you don’t have to do anything here.

3. Copy paste the below code in the file “first_behave.py”

 4. Now right-click on feature in “first_behave.feature” and click “Run….feature file”.

You should notice that the feature will run successfully. A browser will pop up and close, which is fine. The output is as below

 

first_behave_run_successful

 

5. If you would like to run it from command line , do the following from the root of the project i.e. from “python_behave_template” directory. Running from command line will help us align with “Continuous Test Automation” in the future (also with continuous integration)

first_behave_run_successful_cmd

Summary: As you can see behave aligns very much with the Cucumber style of ATDD and so far, it looks exactly like cucumber on ruby OR cucumber-jvm on Java side. Good to go right !

Next we will write our first selenium based behave scenario

First behave Scenario