Now, We need to create feature files and environment.py file under the project folder. For more information on behave python concepts please look into the behave tutorials.
Here we have written feature files for contactUsForm and Login functionality.
or more information on the feature file look into the behave tutorials.
environment.py :
In this file we can configure the methods such as before_all() and after_all() to execute before the test suite and after the test suite.
before_all() : In this method we will be configuring to launch an App by using required capabilities.
after_all() : In this method we will quit the driver.
For more information on the environment.py file look into the behave tutorials of environment.py concept.
Here “environment.py” filename is a constant name. We shouldn't change the name of a file. If we change the name then it throws an error while execution.
environment.py
import time
from base.DriverClass import Driver
import utilities.CustomLogger as cl
log = cl.customLogger()
def before_all(context):
print('Before Class')
context.driver1 = Driver()
context.driver = context.driver1.getDriverMethod()
print('After Class')
def after_all(context):
time.sleep(5)
context.driver.quit()
log.info("Automation Ended")
contactUsFormTest.feature
# This is a Feature file
Feature: Fill the Contact Form
Scenario: Contact form page.
Given Create the class objects of cfp
When Click on Contact Form Button
Then verify Contact form page
And Enter the data in Contact form
loginTest.feature
# This is a Feature file
Feature: Login functionality test
Scenario: Verify Login feature
Given Create the class objects of login page
When Click on Login Button
Then Enter the login credentials
And verify Login page