diff --git a/.gitignore b/.gitignore index afb1aa4..8919059 100644 --- a/.gitignore +++ b/.gitignore @@ -13,10 +13,12 @@ screenshots/ *.pyc geckodriver.log .vscode/settings.json -/allure-results/ +allure-reports +allure-results .DS_Store .AppleDouble /framework/practice.py + diff --git a/Dockerfile b/Dockerfile index f160948..753bbef 100644 --- a/Dockerfile +++ b/Dockerfile @@ -29,6 +29,8 @@ RUN poetry config virtualenvs.create false \ && poetry install --no-interaction --no-ansi # Copy the source code into the image. +RUN mkdir allure-report COPY framework ./framework COPY tests ./tests COPY pytest.ini ./ + diff --git a/Jenkinsfile b/Jenkinsfile index 4152c1a..9f57d64 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -1,25 +1,48 @@ pipeline { - agent any environment { - HEADLESS = '-e RUN_HEADLESS=True' RUN_HEADLESS = 'True' + HEADLESS = '-e RUN_HEADLESS=True' } stages { stage("create docker image") { steps { + catchError{ echo "========== start building image ==========" + sh "env" +// sh "docker rm example1" sh "docker build -t web_test ." -// sh "env" -// sh "docker run --rm $HEADLESS web_test pytest" - sh "docker run --rm -e RUN_HEADLESS=True web_test pytest -s tests/negative_tests/test_authorization_user_negative.py" - sh "docker run --rm -e RUN_HEADLESS=True web_test pytest -s tests/positive_tests/test_making_orders_positive.py" - sh "docker run --rm -e RUN_HEADLESS=True web_test pytest -s tests/positive_tests/test_search_module_operation.py" - sh "docker run --rm -e RUN_HEADLESS=True web_test pytest -s tests/positive_tests/test_registration_and_authorization_positive.py" + sh "docker run \ + -e RUN_HEADLESS=True \ + --name example1 \ + --rm \ + --volume ${WORKSPACE}/allure-results/:/code/allure-results/ \ + web_test \ + pytest tests/negative_tests/test_general_checks.py::TestGeneralChecks::test_check_wrong_title_of_the_page" + +// web_test pytest -s tests/negative_tests/test_authorization_user_negative.py +// sh "docker run --rm -e RUN_HEADLESS=True web_test pytest -s tests/positive_tests/test_making_orders_positive.py" +// sh "docker run --rm -e RUN_HEADLESS=True web_test pytest -s tests/positive_tests/test_search_module_operation.py" +// sh "docker run --rm -e RUN_HEADLESS=True web_test pytest -s tests/positive_tests/test_registration_and_authorization_positive.py" + echo "========== finish building image ==========" } } + } + stage('reports') { + steps { + script { + allure([ + includeProperties: false, + jdk: '', + properties: [], + reportBuildPolicy: 'ALWAYS', + results: [[path: 'allure-results']] + ]) + } + } + } + } } - diff --git a/framework/features/automationpractice/data/data_user_for_registration.py b/framework/features/automationpractice/data/data_user_for_registration.py index f6f936b..bce95b7 100644 --- a/framework/features/automationpractice/data/data_user_for_registration.py +++ b/framework/features/automationpractice/data/data_user_for_registration.py @@ -37,5 +37,5 @@ class DataUserForRegistration: EMAIL_ADDRESS_WITHOUT_DOMAIN = 'email_without_domain@' EMAIL_ADDRESS_WITHOUT_AT = 'email_without_atgmail.com' EMAIL_ADDRESS_WITHOUT_DOT = 'email_without_dot@gmailcom' - EMAIL_ADDRESS_WITH_SPEC_CHARACTER = 'email_with_t№$@gmailcom' + EMAIL_ADDRESS_WITH_SPEC_CHARACTER = 'email_with_spec_chraracter_№$@gmailcom' diff --git a/framework/features/automationpractice/main_page.py b/framework/features/automationpractice/main_page.py index b5ddf4f..9d8877f 100644 --- a/framework/features/automationpractice/main_page.py +++ b/framework/features/automationpractice/main_page.py @@ -54,6 +54,10 @@ def check_title_order_page(self): title = self.element.selenium.get_title_page() assert title == "Order - My Store" + def check_title_main_page_wrong(self): + title = self.element.selenium.get_title_page() + assert title == "My Store1" + def fill_search_field_and_assert_result(self): search_field = self.element.search_field.find_if_visible() self.element.selenium.input(search_field, self.data_product.PRODUCT_WITH_NAME_BLOUSE) diff --git a/framework/utils.py b/framework/utils.py index a70f1af..ffc52e6 100644 --- a/framework/utils.py +++ b/framework/utils.py @@ -8,8 +8,6 @@ from selenium.webdriver.support.select import Select - - class SeleniumBase: def __init__(self, driver, locator=None): self.driver = driver diff --git a/pytest.ini b/pytest.ini index ec7de5c..6c14450 100644 --- a/pytest.ini +++ b/pytest.ini @@ -1,3 +1,4 @@ [pytest] -addopts = -v --reruns=5 +addopts =-v --reruns=1 --alluredir=allure-results/ + diff --git a/tests/README.md b/tests/README.md index f1821b6..097354a 100644 --- a/tests/README.md +++ b/tests/README.md @@ -1,4 +1,4 @@ -## Installing and running a test framework on a local machine +## Installing and running the test framework locally ### Via Jenkins (local) The developer of this framework expects that Jenkins (CI) is installed and configured on your local machine #### To run a project inside Jenkins, you need: diff --git a/tests/negative_tests/test_authorization_user_negative.py b/tests/negative_tests/test_authorization_user_negative.py index 85730a1..1547de3 100644 --- a/tests/negative_tests/test_authorization_user_negative.py +++ b/tests/negative_tests/test_authorization_user_negative.py @@ -1,10 +1,12 @@ - +import allure import pytest from framework.features.automationpractice.automationpractice_app import AutomationpracticeApp from framework.features.automationpractice.data.data_user_for_registration import DataUserForRegistration @pytest.mark.usefixtures("set_up_webdriver") class TestAuthorizationRegistrationNegative: + @allure.description("In that test we try login with invalid credentials") + @allure.severity(severity_level="CRITICAL") def test_authorization_with_invalid_credentials_negative(self): automation_practice = AutomationpracticeApp(self.driver) sign_in = automation_practice.sign_in_page @@ -13,18 +15,18 @@ def test_authorization_with_invalid_credentials_negative(self): sign_in.assert_authentication_failed() - - @pytest.mark.parametrize('email', [ - DataUserForRegistration.EMAIL_ADDRESS_WITHOUT_DOMAIN, - DataUserForRegistration.EMAIL_ADDRESS_WITHOUT_AT, - DataUserForRegistration.EMAIL_ADDRESS_WITHOUT_DOT, - DataUserForRegistration.EMAIL_ADDRESS_WITH_SPEC_CHARACTER - ]) - def test_registration_with_invalid_data_in_email_address_negative(self,email): - automation_practice = AutomationpracticeApp(self.driver) - sign_in = automation_practice.sign_in_page - automation_practice.go_to("index.php?controller=authentication&back=my-account") - sign_in.registration_with_invalid_email(email) - sign_in.assert_invalid_email_address() + # @allure.description("In that test we try to registration with invalid data in email address") + # @pytest.mark.parametrize('email', [ + # DataUserForRegistration.EMAIL_ADDRESS_WITHOUT_DOMAIN, + # DataUserForRegistration.EMAIL_ADDRESS_WITHOUT_AT, + # DataUserForRegistration.EMAIL_ADDRESS_WITHOUT_DOT, + # DataUserForRegistration.EMAIL_ADDRESS_WITH_SPEC_CHARACTER + # ]) + # def test_registration_with_invalid_data_in_email_address_negative(self,email): + # automation_practice = AutomationpracticeApp(self.driver) + # sign_in = automation_practice.sign_in_page + # automation_practice.go_to("index.php?controller=authentication&back=my-account") + # sign_in.registration_with_invalid_email(email) + # sign_in.assert_invalid_email_address() diff --git a/tests/negative_tests/test_general_checks.py b/tests/negative_tests/test_general_checks.py new file mode 100644 index 0000000..42950c9 --- /dev/null +++ b/tests/negative_tests/test_general_checks.py @@ -0,0 +1,16 @@ +import allure +import pytest +from framework.features.automationpractice.automationpractice_app import AutomationpracticeApp + +@pytest.mark.usefixtures("set_up_webdriver") +class TestGeneralChecks: + @allure.description("In that test we try assert wrong title main page") + @allure.severity(severity_level="MINOR") + def test_check_wrong_title_of_the_page(self): + automation_practice = AutomationpracticeApp(self.driver) + main_page = automation_practice.main_page + automation_practice.go_to("index.php") + main_page.check_title_main_page_wrong() + + +