tests package

Here first we will create a conftest.py file and in this we will create a beforeClass method along with pytest fixtures and yield which helps to perform teardown action.

In this package we will create classes for respective pages and call the methods which we have created in the above pages package.

Here we will create methods under that specific method we will call methods which we have created in page classes to form a test case.

In this file we will create methods as per test scenarios and append run order for that.

1. First Scenario

  • Launch the App
  • Click on contact us form button
  • Verify app screen

2. Second Scenario

  • Enter the details such as name,email,address and number
  • Click on the submit button



test_ContactUsFormTest.py

import unittest
import pytest
from AppiumFrameWork.pages.ContactUsFormPage import ContactForm
import AppiumFrameWork.utilities.CustomLogger as cl


@pytest.mark.usefixtures("beforeClass", "beforeMethod")
class ContactFormTest(unittest.TestCase):

    @pytest.fixture(autouse=True)
    def classObjects(self):
        self.cf = ContactForm(self.driver)

    @pytest.mark.run(order=2)
    def test_enterDataInForm(self):
        self. cf.enterName()
        self.cf.enterEmail()
        self.cf.enterAddress()
        self.cf.enterMNumber()
        self.cf.clickSubmitButton()

    @pytest.mark.run(order=1)
    def test_opencontactForm(self):
        cl.allureLogs("App Launched")
        self.cf.clickContactFormButton()
        self.cf.verifyContactPage()


In this test_LoginTest.py file we will create methods as per test scenarios of login functionality and append run order for that.

test_LoginTest.py

import unittest
import pytest
import AppiumFrameWork.utilities.CustomLogger as cl
from AppiumFrameWork.base.BasePage import BasePage
from AppiumFrameWork.pages.LoginPage import LoginPageTest


@pytest.mark.usefixtures("beforeClass", "beforeMethod")
class LoginTest(unittest.TestCase):

    @pytest.fixture(autouse=True)
    def classObjects(self):
        self.gt = LoginPageTest(self.driver)
        self.bp = BasePage(self.driver)

    @pytest.mark.run(order=5)
    def test_enterDataInEditBox(self):
        self.gt.enterText()
        self.gt.clickOnSubmit()

    @pytest.mark.run(order=4)
    def test_openLoginScreen(self):
        self.gt.keyCode(4)
        self.gt.clickLoginBotton()
        self.gt.enterEmail()
        self.gt.enterPassword()
        self.gt.clickOnLoginB()
        self.gt.verifyAdminScreen()

    @pytest.mark.run(order=3)
    def test_loginFailMethod(self):
        cl.allureLogs("App Opened")
        self.gt.clickLoginBotton()
        self.gt.enterEmail()
        self.gt.enterPassword2()
        self.gt.clickOnLoginB()
        self.gt.verifyAdminScreen()