diff --git a/Data/data.py b/Data/data.py index 5764ede1..1607f451 100644 --- a/Data/data.py +++ b/Data/data.py @@ -17,6 +17,12 @@ EMAIL_STUDENT_KM = "student-test-misliplav@mail.ru" PASSWORD_STUDENT_KM = "JXvNebAMsWb7" +EMAIL_TUTOR_ZU = "zayatest55@gmail.com" +PASSWORD_TUTOR_ZU = "RM7tAgSYSh7X" + +EMAIL_STUDENT_ZU = "zarinatest4@gmail.com" +PASSWORD_STUDENT_ZU = "q2e6hXVgsy0W" + def generate_valid_password(): # Определим минимальную длину пароля diff --git a/components/announcement.py b/components/announcement.py index b48baf48..4bddc958 100644 --- a/components/announcement.py +++ b/components/announcement.py @@ -4,6 +4,7 @@ from core.settings import list_url from core.settings import edit_announcement_url import re +import random class Announcement: @@ -40,17 +41,26 @@ def upload_photo(self): "upload_files", "stock-photo-handsome-cheerful-man.jfif", ) - photo_field = self.page.locator("#id_photo") + photo_field = self.page.locator("input#photoInput") photo_field.set_input_files(photo_path) except Exception as e: print(f"First upload error: {e}") try: - self.page.locator('input[name="photo"]').set_input_files( + self.page.locator("input#photoInput").set_input_files( "Data/upload_files/stock-photo-handsome-cheerful-man.jfif" ) except Exception as e: print(f"Second upload failed with error: {e}") + @allure.step("Выберите возрастные категории учеников") + def pick_student_age_category(self): + age_category_elements = self.page.query_selector_all( + '//div[@id="div_id_student_categories"]//input[@type="checkbox"]' + ) + random_choice = random.choice(age_category_elements) + random_choice.click() + assert random_choice.is_checked() + @allure.step("Выбираем категорию") def pick_category(self, category): dropdown = self.page.locator("#id_category") @@ -91,21 +101,6 @@ def fill_out_class_duration(self, duration): if duration == "60": assert filled_value == "60", "The class duration should be 60 minutes" - @allure.step("Продавать пакеты со скидкой") - def checkbox_discount(self): - discount_checkbox = self.page.locator("#id_package_discounts") - discount_checkbox.check() - assert ( - discount_checkbox.is_checked() - ), "The 'has degree' checkbox should be checked" - - @allure.step('Заполняем поле "Удобное время для занятий"') - def fill_out_convenient_time(self): - self.page.fill( - "#id_convenient_time_slots", - "Понедельник-Пятница с 10.00-11.00 Суббота и Воскресенье выходные", - ) - @allure.step("Отчищаем чекбоксы категорий учеников") def clear_student_category_checkboxes(self): checkboxes = self.page.locator( @@ -116,9 +111,11 @@ def clear_student_category_checkboxes(self): if checkboxes.nth(i).is_checked(): checkboxes.nth(i).uncheck() + @allure.step("С чем вы можете помочь") def fill_out_can_help_field(self, text): self.page.fill("#id_can_help", text) + @allure.step("Расскажите о том как проходит урок") def fill_out_lesson_style(self, text): self.page.fill("#id_lesson_style", text) @@ -141,7 +138,12 @@ def verify_announcements_page_endpoint(self): announcement_page_endpoint = "/listings/list/" current_url = self.page.url print(current_url) - assert announcement_page_endpoint in current_url + try: + assert ( + announcement_page_endpoint in current_url + ), f"Expected '{announcement_page_endpoint}' to be in '{current_url}'" + except AssertionError as e: + (print(e)) @allure.step("Кликаем на кнопку 'Мое объявление' в хедере") def click_my_announcement_button(self): @@ -243,24 +245,25 @@ def verify_required_fields_are_not_filled(self): ).count() print(f"Found {error_message_count} error messages.") assert ( - error_message_count == 8 - ), f"Expected 8 error messages, but found {error_message_count}" + error_message_count == 12 + ), f"Expected 12 error messages, but found {error_message_count}" @allure.step("Создаем объявление") def create_announcement(self): - self.fill_first_name("Thomas") - self.fill_last_name("Peters") - self.fill_telegram("ThomasP") - self.fill_phone_number("14103902623") + self.fill_first_name("John") + self.fill_last_name("Pak") + self.fill_telegram("@JPak") + self.fill_phone_number("5555555") self.fill_out_description("Great teacher") + self.pick_student_age_category() self.upload_photo() + self.fill_out_lesson_style("Fast") + self.fill_out_can_help_field("Guaranteed success") self.pick_category("1") self.fill_out_experience("5") self.checkbox_degree() self.fill_out_price("1000") self.fill_out_class_duration("60") - self.checkbox_discount() - self.fill_out_convenient_time() self.click_save_announcement_btn() @allure.step("Создаем объявление с обязательными полями") @@ -270,12 +273,14 @@ def create_announcement_with_only_required_fields(self): self.fill_telegram("ThomasP") self.fill_phone_number("14103902623") self.fill_out_description("Great teacher") + self.fill_out_can_help_field() + self.fill_out_lesson_style() + self.pick_student_age_category() self.upload_photo() self.pick_category("1") self.fill_out_experience("5") self.fill_out_price("1000") self.fill_out_class_duration("60") - self.fill_out_convenient_time() self.click_save_announcement_btn() @allure.step( diff --git a/components/cookie_banner.py b/components/cookie_banner.py index 620bd822..706dbb55 100644 --- a/components/cookie_banner.py +++ b/components/cookie_banner.py @@ -48,9 +48,9 @@ def cookie_text_matches(self): ) actual_text = cookie_text.text_content() expected_text = "Мы используем куки для улучшения вашего опыта на нашем сайте. Вы можете управлять своими предпочтениями." - assert actual_text == expected_text, ( - f"Ожидается '{expected_text}', но получен '{actual_text}'" - ) + assert ( + actual_text == expected_text + ), f"Ожидается '{expected_text}', но получен '{actual_text}'" return True except TimeoutError: raise AssertionError("Cookie banner not found within 5 seconds") diff --git a/components/find_tutor.py b/components/find_tutor.py index 68bacde0..83d4ee7e 100644 --- a/components/find_tutor.py +++ b/components/find_tutor.py @@ -66,9 +66,9 @@ def check_message_of_registration(self, expected_message): alert_locator = self.page.locator("//div[@role='alert']") self.page.wait_for_selector("//div[@role='alert']", timeout=7000) message = alert_locator.text_content() - assert message.strip() == expected_message, ( - f"Expected text is '{expected_message}', but received '{message.strip()}'" - ) + assert ( + message.strip() == expected_message + ), f"Expected text is '{expected_message}', but received '{message.strip()}'" @allure.step("Проверяем фильтр по категории") def check_filter_form(self): @@ -148,9 +148,9 @@ def check_experience_over_min_value(self, min_experience: int): "//p[contains(text(),'лет')]" ).inner_text() experience_value = int(experience_text.split()[0]) - assert experience_value >= min_experience, ( - f"The Teaching Experience {experience_value} less than expected minimum {min_experience}" - ) + assert ( + experience_value >= min_experience + ), f"The Teaching Experience {experience_value} less than expected minimum {min_experience}" self.page.go_back() @@ -202,12 +202,12 @@ def set_random_min_price(self, fake, min_value: int, max_value: int): def enter_min_experience(self, min_experience: int): experience_field = self.page.locator("#minExperience") experience_field.wait_for(state="visible", timeout=3000) - assert experience_field.is_visible(), ( - "The 'Minimum Teaching Experience' field is not visible." - ) - assert experience_field.is_enabled(), ( - "The 'Minimum Teaching Experience' field is not enabled." - ) + assert ( + experience_field.is_visible() + ), "The 'Minimum Teaching Experience' field is not visible." + assert ( + experience_field.is_enabled() + ), "The 'Minimum Teaching Experience' field is not enabled." experience_field.fill(str(min_experience)) @allure.step("Проверяем страница Профайл репетитора содержит требующие детали") @@ -227,9 +227,9 @@ def check_tutor_profile_has_require_details(self): count_ld_items = lesson_details.count() for i in range(count_ld_items): elem = lesson_details.nth(i) - assert elem.is_visible(), ( - f"Element Lesson details at index {i} is not visible" - ) + assert ( + elem.is_visible() + ), f"Element Lesson details at index {i} is not visible" elem_text = elem.inner_text().strip() assert elem_text != "", f"Text Lesson details at index {i} is empty" # Verify Tutor details diff --git a/components/login.py b/components/login.py index 5251b305..7e0a56d0 100644 --- a/components/login.py +++ b/components/login.py @@ -15,9 +15,9 @@ def __init__(self, page: Page): @allure.step("Проверяем URL страницы 'Логин'") def check_url_login_page(self, expected_part: str): current_url = self.page.url - assert expected_part in current_url, ( - f"Ожидалось, что '{expected_part}' будет частью '{current_url}'" - ) + assert ( + expected_part in current_url + ), f"Ожидалось, что '{expected_part}' будет частью '{current_url}'" @allure.step("Проверяем наличие кнопки 'Регистрация'") def check_title_of_registration(self): diff --git a/components/register.py b/components/register.py index 566ae487..2bb1fea8 100644 --- a/components/register.py +++ b/components/register.py @@ -43,9 +43,9 @@ def click_registration_button(self): @allure.step("Проверяем, что страница регистрации открыта") def verify_registration_page_opened(self): registration_title = self.page.locator("h1").inner_text() - assert registration_title == "Регистрация", ( - f"Ожидался заголовок 'Регистрация', но найдено: {registration_title}" - ) + assert ( + registration_title == "Регистрация" + ), f"Ожидался заголовок 'Регистрация', но найдено: {registration_title}" @allure.step("Создаем случайный пароль") def generate_valid_password(self): diff --git a/tests/test_announcement.py b/tests/test_announcement.py index a819fe0b..9fa7dc4b 100644 --- a/tests/test_announcement.py +++ b/tests/test_announcement.py @@ -4,10 +4,9 @@ # TC_12.002.001| [Teacher] Create announcement > Create teacher announcement. # Verify the announcement is created after filling in all form fields with valid data#163 @pytest.mark.skip(reason="Тест временно отключен после обновления 09.01.2025") -def test_create_announcement(header, announcement, register): +def test_create_announcement(header, announcement, login): header.visit() - header.click_registration_button() - register.registration_new_user("tutor") + login.full_login("zayatest55@gmail.com", "RM7tAgSYSh7X") header.click_create_announcement_btn() announcement.create_announcement() announcement.verify_announcements_page_endpoint() @@ -19,7 +18,7 @@ def test_teacher_announcement_blank_form_same_endpoint( header, login, create_announcement_page, announcement ): header.visit() - login.full_login("zayatest55@gmail.com", "RM7tAgSYSh7X") + login.full_login("zpak7760@gmail.com", "q4fLncSv9Lgx") header.click_create_announcement_button() create_announcement_page.click_finalize_announcement_button() announcement.verify_required_fields_are_not_filled() @@ -32,7 +31,7 @@ def test_teacher_announcement_blank_form( header, login, create_announcement_page, announcement ): header.visit() - login.full_login("zayatest55@gmail.com", "RM7tAgSYSh7X") + login.full_login("zpak7760@gmail.com", "q4fLncSv9Lgx") header.click_create_announcement_button() create_announcement_page.click_finalize_announcement_button() announcement.navigate_to_users_announcement_list() @@ -108,12 +107,9 @@ def test_announcement_detailed_info(header, announcement, login): # TC_13.005.002 | [Teacher] My announcements > Hiding announcement > # Verify the teacher is able to the page "Мое объявление"#299" - - -@pytest.mark.skip(reason="Тест временно отключен после обновления 09.01.2025") def test_redirection_to_my_announcement_page(header, announcement, login): header.visit() - login.full_login("teacher-test@gmail.com", "Auah7bD2hS5Si7H") + login.full_login("zayatest55@gmail.com", "RM7tAgSYSh7X") announcement.click_my_announcement_button() diff --git a/tests/test_header.py b/tests/test_header.py index 70653285..03d045a0 100644 --- a/tests/test_header.py +++ b/tests/test_header.py @@ -123,7 +123,7 @@ def test_my_students_btn_is_not_visible_for_students(login, header): # "Мои студенты" button is not available when no announcement is created def test_my_students_btn_is_not_visible_for_teacher_with_no_announcement(login, header): header.visit() - login.full_login("zayatest55@gmail.com", "RM7tAgSYSh7X") + login.full_login("zpak7760@gmail.com", "q4fLncSv9Lgx") assert header.my_students_button_is_hidden() is True @@ -150,9 +150,9 @@ def test_header_home_btn_is_visible_on_all_pages_for_guest(header): header.page.goto(page_url) home_btn = header.header_home_btn_is_present() - assert home_btn.is_visible(), ( - f"Home button is not visible on the page with url {page_url}" - ) + assert ( + home_btn.is_visible() + ), f"Home button is not visible on the page with url {page_url}" # TC_31.002.001.001 Header-Student > Sign out > Visibility "Выйти" button