Steps definition Files

Here under the steps package we need to define all the test files which are based on feature files.

Under the steps package we have defined the step definition files for each feature file by using locators and methods which are defined in pages.

Step definition files in the steps package are based on feature files.

Here we have written step definitions for those 2 feature files of contact form and enter text.


ContactFormtest.py


import time

from behave import step,given,when,then

from base.BasePage import BaseClass
from pages.ContctFormPage import ContactForm



class ContactFormTest:

    @given("Create the class objects in cfp")
    def classObjects(context):
        context.cf = ContactForm(context.driver)
        context.bp = BaseClass(context.driver)


    @when("Click Contact Form")
    def contactformPage(context):
        context.cf.clickContactForm()

    @then("verify form page")
    def verifyContactForm(context):
        context.cf.verifyFormPage()


    @then("Enter the data in form")
    def enterDataInForm(context):
        time.sleep(5)
        context.cf.enterName()
        context.cf.enterEmail()
        context.cf.enterMessage()
        context.cf.enterCaptha()
        context.cf.clickOnPostButton()





EnterText.py


import time
from behave import given,when,then
from pages.EnterTextPage import EnterText


class EnterTextTest:


    @given("Create the class objects")
    def classObjects(context):
        context.et = EnterText(context.driver)
        print(context.testVariable)


    @when("Click on Locators Page")
    def clickOnLocatorsPage(context):
        context.et.clickOnLocatorsPage()

    @when("Enter Data")
    def enterDataInEditBox(context):
        context.driver.maximize_window()
        time.sleep(2)
        context.et.enterText()

    @then("CLick on Submit button")
    def clickOnSubmitB(context):
        context.et.clickOnSubmitButton()