Feature files

Feature files

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 of contactForm and enter text in the edit box.

For 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 a webpage by using required browser drivers.

after_all() : In this method we will quit the browser driver.

For more information on environment.py file look into the behave tutorials of Setup and Teardown in Behave.

Here “environment.py” filename is a constant name. We shouldn't change the name of a file. If we do it throws an error while execution.




environment.py


import time
from behave import step
from base.BasePage import BaseClass
from base.DriverClass import WebDriverClass
import utilities.CustomLogger as cl
import configurationfiles.DeviceConfig as dc

log = cl.customLogger()


def before_all(context):
    log.info("Automation Started")
    context.testVariable = "This is a Test variable"
    context.driver1 = WebDriverClass()
    context.driver = context.driver1.getWebDriver(dc.bName)
    context.bp = BaseClass(context.driver)
    context.bp.launchWebPage(dc.url, dc.title)


def after_all(context):
    time.sleep(5)
    context.driver.quit()
    log.info("Automation Ended")



We have written the feature file for the contact form.


Contact US Form

contactForm.feature

# This is a Feature file


Feature: Fill the Contact Form


    Scenario: Contact form page

        Given Create the class objects in cfp
        When Click Contact Form
        Then verify form page
        And Enter the data in form




We have written the feature file for the enter text.


Enter text

EnterTextPage.feature

# This is a Feature file


Feature: Fill the data in editbox


    Scenario: EditBox data

        Given Create the class objects
        When Click on Locators Page
        When Enter Data
        Then CLick on Submit button