# apollo-web-pw-automation

# Playwright-based Test Automation Framework for the Apollo Web Portal

Overview
=============
* Require Python 3.8+ version
* Framework is based on the page object model.
* Added Allure as reporting tool.
* Reading credentials from environment variables.
* Supports taking screenshots during failure and verification step.

# SETUP with PLAYWRIGHT:
https://playwright.dev/python/docs/intro
1. pip install pytest-playwright
2. playwright install
3. Run tests using pytest

**Install locally:**
1. Setup Playwright for python:
https://pypi.org/project/pytest-playwright/

3. Install requirements and dependencies:
pip install -r requirements/base.txt


RUN:
====
#### Run specific test suite:

sh
py.test --html=report.html --self-contained-html  --alluredir=allure_report src/tests/test_track_page.py -n 4 --reruns 1

To run tests in parallel add option:

-n {streams_count}


To add reruns for failed test:
--reruns {reruns_count}

**Or create run configuration in IDE.**


REPORTING:
===
Both Allure and pytests reports are available

Generating allure report:
sh
make report

PyTest report is available after run as report.html file


CREATION OF YOUR OWN UI TEST:
===
All application-related code is stored in app/ directory.
Pages, actions and business logic are stored in app/pages/ directory and named accordingly to represented page.

    class LoginPage:
        def __init__(self, page: Page):
            self.page = page

        def check_title(self):
            expect(self.page).to_have_title('DNA')

        def start_searching(self):
            self.page.click("text=Start Searching")

        def menu_searches(self):
            self.page.click("xpath=//*[@id=\"root\"]/div/aside/div/nav/ul/li[2]/a")

        def start_new_search(self):
            self.page.click("text=Start new Search")

UI elements described in src/locators/ directory  in .py files named accordingly to represented page. Locator description includes related page, location strategy (xpath, css..) and locator itself.

         PASSWORD_FIELD = ("name", "passwd")

Tests are stored in src/tests/ dir and describe test flow, test file should contain 'test' in file name in order to pytest can collect it (test_login.py)':

    @allure.story("POC scope")
    @allure.severity(allure.severity_level.CRITICAL)
    @allure.title("Verifying all users notifications")
    def test_login(self):
        self.app.go_to('')

        self.login_page.check_title()

        self.login_page.start_searching()
        self.login_page.menu_searches()
        self.login_page.start_new_search()


TAKING SCREENSHOTS
===
Screenshots will be automatically taken during failure and attached to the allure report.
All screenshots will be saved under app/src/screenshots/ dir

***Windows Configuration - to run tests in docker locally***
1. AWS Console installed and properly configured 
2. using GitBash run 
make docker/image/build -n
3. from command output - copy 'docker build' command and run it from GitBash
4. set env variables
5. run make docker/test-win
