diff --git a/locators/authotised_user_home_page_locators.py b/locators/authorised_user_home_page_locators.py similarity index 100% rename from locators/authotised_user_home_page_locators.py rename to locators/authorised_user_home_page_locators.py diff --git a/pages/autorized_user_home_page.py b/pages/autorized_user_home_page.py index 5dbe8eee76..40b90fbedc 100644 --- a/pages/autorized_user_home_page.py +++ b/pages/autorized_user_home_page.py @@ -1,5 +1,5 @@ import allure -from locators.authotised_user_home_page_locators import AuthorizedUserHomePageLocators +from locators.authorised_user_home_page_locators import AuthorizedUserHomePageLocators from pages.base_page import BasePage diff --git a/pages/base_page.py b/pages/base_page.py index 3c4d7e9595..eea6c98fee 100644 --- a/pages/base_page.py +++ b/pages/base_page.py @@ -86,9 +86,18 @@ def check_expected_link(self, url): def wait_changed_url(self, url): with allure.step(f'Wait until url: {url} will be changed.'): - Wait(self.driver, self.timeout).until( + Wait(self.driver, timeout=20).until( EC.url_changes(url), message=f"Url: {url} has not been changed!!!") + def check_has_not_changed_url(self, url): + with allure.step(f"Wait until url: {url} hasn't changed."): + try: + Wait(self.driver, self.timeout).until(EC.url_changes(url), message=f"Url: {url} hasn't changed!!!") + return False + except TimeoutException: + return True + + def wait_url_to_be(self, url): with allure.step(f'Wait until url to be: {url}.'): Wait(self.driver, self.timeout).until( diff --git a/pages/profile_page.py b/pages/profile_page.py index b848aa9c99..4e75f9e081 100644 --- a/pages/profile_page.py +++ b/pages/profile_page.py @@ -5,7 +5,7 @@ from dotenv import load_dotenv from selenium.common import TimeoutException from locators.login_page_locators import LoginPageLocators -from locators.authotised_user_home_page_locators import AuthorizedUserHomePageLocators +from locators.authorised_user_home_page_locators import AuthorizedUserHomePageLocators from locators.start_unauthorized_page_locators import StartUnauthorizedPageLocators from locators.profile_page_locators import ProfilePageLocators from pages.base_page import BasePage diff --git a/pages/registration_page.py b/pages/registration_page.py index 8de2acfb00..31a6d3e066 100644 --- a/pages/registration_page.py +++ b/pages/registration_page.py @@ -55,3 +55,7 @@ def check_change_url(self): @allure.step("Check REGISTRATION button is not clickable") def check_registration_button_is_not_clickable(self): self.element_is_not_clickable(self.locators.SUBMIT_BUTTON).click() + + @allure.step("Wait not changing url") + def check_not_change_url(self): + return self.check_has_not_changed_url(self.links.URL_REGISTRATION_PAGE) diff --git a/test_data/registration_data.py b/test_data/registration_data.py index e0c4b6ed19..e1b788cace 100644 --- a/test_data/registration_data.py +++ b/test_data/registration_data.py @@ -19,6 +19,7 @@ class Messages: EMPTY_EMAIL = ['Please enter your login and password', 'Пожалуйста, введите логин и пароль.'] EMPTY_PASSWORD = ['Passwords should match', 'Пароли должны совпадать'] ONLY_FIRST_NAME = ['Empty LastName', 'Фамилия не Указана'] + WITHOUT_AGREEMENT = ['You must agree to the terms before registering', 'Вы должны согласиться с условиями перед регистрацией'] class Registration: diff --git a/tests/registration_page_test.py b/tests/registration_page_test.py index 313edad78e..d9d75cdd10 100644 --- a/tests/registration_page_test.py +++ b/tests/registration_page_test.py @@ -55,8 +55,12 @@ def test_registration_negative(self, driver, main_page_open, title, first_name, page.fill_repeat_password(confirm_password) page.choose_agreement() page.click_registration_button() - text = page.check_error_message() - assert text in error_message, f'The user has registered with {title}' + try: + text = page.check_error_message() + assert text in error_message, f'The user has registered with {title}' + except TimeoutException: + assert page.check_not_change_url() + @allure.title('Check registration without choosing gender') def test_registration_without_choosing_gender(self, main_page_open, driver): @@ -90,7 +94,7 @@ def test_registration_without_choosing_agreement(self, main_page_open, driver): page.fill_repeat_password(os.environ["CHANGE_PASSWORD"]) page.click_registration_button() try: - page.check_change_url() + text = page.check_error_message() + assert text in self.msg.WITHOUT_AGREEMENT, 'The user has registered without agreement' except TimeoutException: - pass - assert TimeoutException, 'The user has registered without choosing agreement' + assert page.check_not_change_url()