Skip to content

Commit 5ad8c79

Browse files
authored
issue_669: fix registration_page_test.py (#670)
1 parent 7c40fa7 commit 5ad8c79

7 files changed

Lines changed: 26 additions & 8 deletions

File tree

File renamed without changes.

pages/autorized_user_home_page.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import allure
2-
from locators.authotised_user_home_page_locators import AuthorizedUserHomePageLocators
2+
from locators.authorised_user_home_page_locators import AuthorizedUserHomePageLocators
33
from pages.base_page import BasePage
44

55

pages/base_page.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,9 +86,18 @@ def check_expected_link(self, url):
8686

8787
def wait_changed_url(self, url):
8888
with allure.step(f'Wait until url: {url} will be changed.'):
89-
Wait(self.driver, self.timeout).until(
89+
Wait(self.driver, timeout=20).until(
9090
EC.url_changes(url), message=f"Url: {url} has not been changed!!!")
9191

92+
def check_has_not_changed_url(self, url):
93+
with allure.step(f"Wait until url: {url} hasn't changed."):
94+
try:
95+
Wait(self.driver, self.timeout).until(EC.url_changes(url), message=f"Url: {url} hasn't changed!!!")
96+
return False
97+
except TimeoutException:
98+
return True
99+
100+
92101
def wait_url_to_be(self, url):
93102
with allure.step(f'Wait until url to be: {url}.'):
94103
Wait(self.driver, self.timeout).until(

pages/profile_page.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
from dotenv import load_dotenv
66
from selenium.common import TimeoutException
77
from locators.login_page_locators import LoginPageLocators
8-
from locators.authotised_user_home_page_locators import AuthorizedUserHomePageLocators
8+
from locators.authorised_user_home_page_locators import AuthorizedUserHomePageLocators
99
from locators.start_unauthorized_page_locators import StartUnauthorizedPageLocators
1010
from locators.profile_page_locators import ProfilePageLocators
1111
from pages.base_page import BasePage

pages/registration_page.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,3 +55,7 @@ def check_change_url(self):
5555
@allure.step("Check REGISTRATION button is not clickable")
5656
def check_registration_button_is_not_clickable(self):
5757
self.element_is_not_clickable(self.locators.SUBMIT_BUTTON).click()
58+
59+
@allure.step("Wait not changing url")
60+
def check_not_change_url(self):
61+
return self.check_has_not_changed_url(self.links.URL_REGISTRATION_PAGE)

test_data/registration_data.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ class Messages:
1919
EMPTY_EMAIL = ['Please enter your login and password', 'Пожалуйста, введите логин и пароль.']
2020
EMPTY_PASSWORD = ['Passwords should match', 'Пароли должны совпадать']
2121
ONLY_FIRST_NAME = ['Empty LastName', 'Фамилия не Указана']
22+
WITHOUT_AGREEMENT = ['You must agree to the terms before registering', 'Вы должны согласиться с условиями перед регистрацией']
2223

2324

2425
class Registration:

tests/registration_page_test.py

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,12 @@ def test_registration_negative(self, driver, main_page_open, title, first_name,
5555
page.fill_repeat_password(confirm_password)
5656
page.choose_agreement()
5757
page.click_registration_button()
58-
text = page.check_error_message()
59-
assert text in error_message, f'The user has registered with {title}'
58+
try:
59+
text = page.check_error_message()
60+
assert text in error_message, f'The user has registered with {title}'
61+
except TimeoutException:
62+
assert page.check_not_change_url()
63+
6064

6165
@allure.title('Check registration without choosing gender')
6266
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):
9094
page.fill_repeat_password(os.environ["CHANGE_PASSWORD"])
9195
page.click_registration_button()
9296
try:
93-
page.check_change_url()
97+
text = page.check_error_message()
98+
assert text in self.msg.WITHOUT_AGREEMENT, 'The user has registered without agreement'
9499
except TimeoutException:
95-
pass
96-
assert TimeoutException, 'The user has registered without choosing agreement'
100+
assert page.check_not_change_url()

0 commit comments

Comments
 (0)