Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
67 changes: 67 additions & 0 deletions components/find_tutor.py
Original file line number Diff line number Diff line change
Expand Up @@ -255,3 +255,70 @@ def check_tutor_profile_btn_request_lesson_clickable_redirect(self):
assert self.page.url == (
"http://tester:dslfjsdfblkhew%40122b1klbfw@testing.misleplav.ru/listings/lesson_request/1/"
)

# TC_39.001.001.001 - 004
@allure.step(
'Проверяем доступность полей на странице "Запрос занятия!"'
)
def verify_fields_to_be_visible_lesson_page(self):
req_id_title = ['div_id_first_name', 'div_id_last_name', 'div_id_telegram', 'div_id_phone', 'div_id_goal', 'div_id_count_of_lessons']
for title in req_id_title:
expect(self.page.locator(f'//div[@id="{title}"]')).to_be_visible()

@allure.step(
'Проверяем кнопку "Отправить" на странице "Запрос занятия!"'
)
def verify_btn_submit_and_pay_is_visible(self):
submit_btn = self.page.locator('//button[@type="submit"]')
assert submit_btn.is_visible()

def click_btn_submit_request(self):
submit_btn = self.page.locator('//button[@type="submit"]')
submit_btn.click()

def fill_fields(self, field_list):
for field in field_list:
locator = self.page.locator(f'//div/*[(self::input or self::textarea) and @id="{field}"]')
val = locator.evaluate("el => el.value")
if not val or not val.strip():
tag_name = locator.evaluate("el => el.tagName.toLowerCase()")
if tag_name == "input":
input_type = locator.get_attribute("type") or ""
if input_type == "number":
locator.fill("33")
else:
locator.fill("TESTING")
elif tag_name == "textarea":
locator.fill("TESTING")

@allure.step(
'Проверяем позитивный кейс по заполнению обязательных полей на странице "Запрос занятия!" и переход на страницу "Dashboard'
)
def verify_positive_require_fields_to_submit(self):
req_id_fields = ['id_first_name', 'id_last_name', 'id_telegram', 'id_phone', 'id_goal', 'id_count_of_lessons']
self.fill_fields(req_id_fields)
self.click_btn_submit_request()
assert self.page.url == (
"http://tester:dslfjsdfblkhew%40122b1klbfw@testing.misleplav.ru/dashboard/dashboard/7/"
)

@allure.step(
'Проверяем отрицательный кейс по заполнению обязательных полей на странице "Запрос занятия!"'
)
def verify_negative_require_fields_to_submit(self):
req_id_fields = ['id_first_name', 'id_last_name', 'id_telegram', 'id_phone', 'id_goal', 'id_count_of_lessons']
for field_to_test in req_id_fields:
error_locator = self.page.locator('//strong[text()="Обязательное поле."]')
self.fill_fields(req_id_fields)
cleared_locator = self.page.locator(f'//div/*[(self::input or self::textarea) and @id="{field_to_test}"]')
cleared_locator.fill("") # Make it empty
self.click_btn_submit_request() # or however you submit the form
assert error_locator.is_visible(), (
f"No 'Обязательное поле.' message for empty field {field_to_test}"
)

@allure.step(
'Проверяем сообщение "Платеж успешно произведен. Скоро с вами свяжемся"'
)
def verify_request_success_message(self):
pass
51 changes: 51 additions & 0 deletions tests/test_find_tutor.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,3 +102,54 @@ def test_tutor_profile_btn_request_lesson_clickable_redirect(login, header, find
login.full_login("acc.python.test@gmail.com", "jUvJ5ZSxzdIr")
find_tutor.check_btn_more_is_clickable()
find_tutor.check_tutor_profile_btn_request_lesson_clickable_redirect()


@allure.title("TC_39.001.001.001")
@allure.link("https://github.com/RedRoverSchool/BookClubQA_Python_2024_fall/issues/417")
# TC_39.001.001.001 [Student ] Find a teacher > More > Lesson request > Verify fields required to be filled
def test_verify_fields_lesson_page(login, header, find_tutor):
header.visit()
login.full_login("acc.python.test@gmail.com", "jUvJ5ZSxzdIr")
find_tutor.check_btn_more_is_clickable()
find_tutor.check_tutor_profile_btn_request_lesson_clickable_redirect()
find_tutor.verify_fields_to_be_visible_lesson_page()


@allure.title("TC_39.001.001.002")
@allure.link("https://github.com/RedRoverSchool/BookClubQA_Python_2024_fall/issues/417")
# TC_39.001.001.002 [Student ] Find a teacher > More > Lesson request > Verify the button "Оплатить и записаться" visible
def test_verify_btn_submit_and_pay(login, header, find_tutor):
header.visit()
login.full_login("acc.python.test@gmail.com", "jUvJ5ZSxzdIr")
find_tutor.check_btn_more_is_clickable()
find_tutor.check_tutor_profile_btn_request_lesson_clickable_redirect()
find_tutor.verify_btn_submit_and_pay_is_visible()


@allure.title("TC_39.001.001.003")
@allure.link("https://github.com/RedRoverSchool/BookClubQA_Python_2024_fall/issues/417")
# TC_39.001.001.003 [Student ] Find a teacher > More > Lesson request > Verify user ABLE to submit form only with require fields
def test_verify_positive_require_fields_to_submit(login, header, find_tutor):
header.visit()
login.full_login("acc.python.test@gmail.com", "jUvJ5ZSxzdIr")
find_tutor.check_btn_more_is_clickable()
find_tutor.check_tutor_profile_btn_request_lesson_clickable_redirect()
find_tutor.verify_positive_require_fields_to_submit()


@allure.title("TC_39.001.001.004")
@allure.link("https://github.com/RedRoverSchool/BookClubQA_Python_2024_fall/issues/417")
# TC_39.001.001.004 [Student ] Find a teacher > More > Lesson request > Verify user UNABLE to submit form if the require field missed
def test_verify_negative_require_fields_to_submit(login, header, find_tutor):
header.visit()
login.full_login("acc.python.test@gmail.com", "jUvJ5ZSxzdIr")
find_tutor.check_btn_more_is_clickable()
find_tutor.check_tutor_profile_btn_request_lesson_clickable_redirect()
find_tutor.verify_negative_require_fields_to_submit()


@allure.title("TC_39.001.001.005")
@allure.link("https://github.com/RedRoverSchool/BookClubQA_Python_2024_fall/issues/417")
# TC_39.001.001.006 [Student ] Find a teacher > More > Lesson request > Verify after submit the request the user receive success message : ""Платеж успешно произведен. Скоро с вами свяжемся""
def test_verify_success_message_of_request(login, header, find_tutor):
pass
Loading