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 contactUsformTest and loginTest.
ContactUsForm.py
import time from behave import step,given,when,then from base.BasePage import BasePage from pages.ContactUsFormPage import ContactForm class ContactUsFormTest: @given("Create the class objects of cfp") def classObjects(context): context.cf = ContactForm(context.driver) context.bp = BasePage(context.driver) @when("Click on Contact Form Button") def contactformPage(context): context.cf.clickContactFormButton() @then("verify Contact form page") def verifyContactForm(context): context.cf.verifyContactPage() @then("Enter the data in Contact form") def enterDataInForm(context): time.sleep(5) context.cf.enterName() context.cf.enterEmail() context.cf.enterAddress() context.cf.enterMNumber() context.cf.clickSubmitButton()
LoginTest.py
import time from behave import step,given,when,then from base.BasePage import BasePage from pages.LoginPage import LoginPageTest class LoginTest: @given("Create the class objects of login page") def classObjects(context): context.gt = LoginPageTest(context.driver) context.bp = BasePage(context.driver) @when("Click on Login Button") def contactformPage(context): context.gt.clickLoginBotton() @then("Enter the login credentials") def enterDataInForm(context): time.sleep(5) context.gt.enterEmail() context.gt.enterPassword() context.gt.clickOnLoginB() @then("verify Login page") def verifyContactForm(context): context.gt.verifyAdminScreen()