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
56 changes: 50 additions & 6 deletions components/find_tutor.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,6 @@ def check_filter_form(self):
all_tutors_math += self.page.get_by_role(
"heading", name="Математика"
).count()

self.page.locator("//select[@id='categorySelect']").select_option("Математика")
self.page.locator("button.btn.btn-primary.btn-lg.me-2").click()
self.page.wait_for_load_state()
Expand Down Expand Up @@ -118,7 +117,6 @@ def enter_min_price(self, min_price: float):
def check_prices_over_min_price(self, min_price: float) -> object:
# Проверяем, есть ли репетиторы на странице
price_siblings_list = self.page.get_by_text("Стоимость занятия:")

if price_siblings_list.count() > 0:
# Если репетиторы есть, то проверяем, что их стоимость занятия >= установленной минимальной цены
for i in range(price_siblings_list.count()):
Expand All @@ -133,6 +131,29 @@ def check_prices_over_min_price(self, min_price: float) -> object:
text = self.page.locator(".bg-white.p-3.mt-3").text_content()
assert "По вашему запросу нет результатов.", text

@allure.step(
"Проверяем, что опыт преподавания репетиторов больше или равен заданному значению"
)
def check_experience_over_min_value(self, min_experience: int):
filtered_cards = self.page.locator("//div[@class='row']/div")

card_count = filtered_cards.count()
assert card_count > 0, "The filter returned an empty list"

for i in range(card_count):
card = filtered_cards.nth(i)
more_details_btn = card.get_by_text("Подробнее")
more_details_btn.click()
experience_text = self.page.locator(
"//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}"

self.page.go_back()

@allure.step('Проверяем видимость кнопки "Фильтровать"')
def check_filter_btn_is_visible(self):
filter_btn = self.page.locator(
Expand All @@ -142,9 +163,13 @@ def check_filter_btn_is_visible(self):

@allure.step('Нажимаем на кнопку "Фильтровать"')
def click_filter_btn(self):
filter_btn = self.page.locator('//button[@type="submit" and contains(@class, "btn-dark") and text()="Вперед"]')
filter_btn = self.page.locator(
'//button[@type="submit" and contains(@class, "btn-dark") and text()="Вперед"]'
)
filter_btn.click()
assert self.page.url == ('http://tester:dslfjsdfblkhew%40122b1klbfw@testing.misleplav.ru/listings/list/?category=&min_experience=0&min_price=&max_price=')
assert self.page.url == (
"http://tester:dslfjsdfblkhew%40122b1klbfw@testing.misleplav.ru/listings/list/?category=&min_experience=0&min_price=&max_price="
)

@allure.step('Проверяем видимость кнопки "Подробнее"')
def check_btn_more_is_visible(self):
Expand All @@ -155,7 +180,9 @@ def check_btn_more_is_visible(self):
def check_btn_more_is_clickable(self):
btn_more = self.page.locator('(//a[text()="Подробнее"])[1]')
btn_more.click()
assert self.page.url == ('http://tester:dslfjsdfblkhew%40122b1klbfw@testing.misleplav.ru/listings/1/')
assert self.page.url == (
"http://tester:dslfjsdfblkhew%40122b1klbfw@testing.misleplav.ru/listings/1/"
)

@allure.step('Проверяем каждый профиль содержит кнопку "Подробнее"')
def check_btn_more_has_each_profile(self):
Expand All @@ -164,4 +191,21 @@ def check_btn_more_has_each_profile(self):
expect(btn_more).not_to_have_count(0, timeout=3000)

for i in range(btn_more.count()):
expect(btn_more.nth(i)).to_be_visible()
expect(btn_more.nth(i)).to_be_visible()

@allure.step("Определяем случайную минимальную цену")
def set_random_min_price(self, fake, min_value: int, max_value: int):
min_price = fake.random_int(min=min_value, max=max_value)
return min_price

@allure.step("Вводим значение минимального опыта преподавания")
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."
experience_field.fill(str(min_experience))
43 changes: 41 additions & 2 deletions components/header.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
import allure
from playwright.sync_api import Page, expect

from core.settings import base_url, my_tutors_list_url, tutors_list_url as find_tutor_url
from core.settings import (
base_url,
my_tutors_list_url,
tutors_list_url as find_tutor_url,
)

profile_page = "http://testing.misleplav.ru/subscription/profile/"

Expand All @@ -16,7 +20,7 @@ def visit(self):

@allure.step("Кликаем на кнопку 'Войти'")
def click_login_button(self):
self.page.get_by_role("link", name="Войти").click()
self.page.locator("//a[text()='Войти']").click()

@allure.step("Кликаем на кнопку 'Регистрация'")
def click_registration_button(self):
Expand Down Expand Up @@ -202,3 +206,38 @@ def hover_profile_btn_color_check(self):
original_color = button.evaluate("el => getComputedStyle(el).color")
button.hover()
expect(button).not_to_have_css("color", original_color)

# TC_31.003.001.001 | [Student ] Header > My Tutor(button) > Visibility check #326

@allure.step("Проверяем видимость кнопки 'Мои репетиторы'")
def student_my_tutors_button_is_visible(self):
my_tutors_btn = self.page.wait_for_selector(
"(//a[@class='nav-link'])[2]", state="visible"
)
return my_tutors_btn.is_visible()

# TC_31.003.001.003 | [Student ] Header > My Tutor(button) > Clickability, Redirect check #326
@allure.step("Проверяем видимость кнопки 'Мои репетиторы'")
def student_my_tutors_button_clickable_redirect(self):
self.page.wait_for_selector(
"(//a[@class='nav-link'])[2]", state="visible"
).click()
current_url = self.page.url
assert current_url == my_tutors_list_url

# TC_31.004.001.001 | [Student ] Header > Find Teacher(button) > Visibility check #321
@allure.step("Проверяем видимость кнопки 'Найти репетитора'")
def student_find_tutor_button_is_visible(self):
find_tutors_btn = self.page.wait_for_selector(
"(//a[@class='nav-link'])[1]", state="visible"
)
return find_tutors_btn.is_visible()

# TC_31.004.001.003 | [Student ] Header > Find Teacher(button) > Clickability, Redirect check #321
@allure.step("Проверяем видимость кнопки 'Мои репетиторы'")
def student_find_tutor_button_clickable_redirect(self):
self.page.wait_for_selector(
"(//a[@class='nav-link'])[1]", state="visible"
).click()
current_url = self.page.url
assert current_url == find_tutor_url
9 changes: 5 additions & 4 deletions components/login.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from core.settings import login_url
from dotenv import load_dotenv
import os
import time


load_dotenv()

Expand Down Expand Up @@ -76,7 +76,7 @@ def enter_password(self, password: str):

@allure.step("Нажимаем кнопку 'Войти'")
def click_login_button(self):
self.page.get_by_text("Войти").click()
self.page.locator("//a[text()='Войти']").click()

@allure.step("Выполняем полный вход пользователя")
def full_login(self, username: str, password: str):
Expand All @@ -92,11 +92,12 @@ def full_login(self, username: str, password: str):

@allure.step("Выполняем вход с не корректным логином")
def check_enter_invalid_username(self, username):

self.enter_username(username)

def should_be_valid_error_message(self):
error_message = self.page.locator('li:has-text("Пожалуйста, введите правильные Почта и пароль. Оба поля могут быть чувствительны к регистру.")')
error_message = self.page.locator(
'li:has-text("Пожалуйста, введите правильные Почта и пароль. Оба поля могут быть чувствительны к регистру.")'
)
if error_message.is_visible():
print("Error message found!")

Expand Down
12 changes: 9 additions & 3 deletions core/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,16 @@
fake_name_for_registration = fake.user_name()

policy_url = "https://www.example.com/privacy-policy"
list_url = "http://tester:dslfjsdfblkhew%40122b1klbfw@testing.misleplav.ru/listings/list/"
tutors_list_url = "http://tester:dslfjsdfblkhew%40122b1klbfw@testing.misleplav.ru/listings/list/"
list_url = (
"http://tester:dslfjsdfblkhew%40122b1klbfw@testing.misleplav.ru/listings/list/"
)
tutors_list_url = (
"http://tester:dslfjsdfblkhew%40122b1klbfw@testing.misleplav.ru/listings/list/"
)
list_url = "http://tester:dslfjsdfblkhew%40122b1klbfw@testing.misleplav.ru/list/"
tutors_list_url = "http://tester:dslfjsdfblkhew%40122b1klbfw@testing.misleplav.ru/listings/list/"
tutors_list_url = (
"http://tester:dslfjsdfblkhew%40122b1klbfw@testing.misleplav.ru/listings/list/"
)
my_tutors_list_url = "http://tester:dslfjsdfblkhew%40122b1klbfw@testing.misleplav.ru/dashboard/my_teachers/"
signup_url = "http://tester:dslfjsdfblkhew%40122b1klbfw@testing.misleplav.ru/authorization/signup/"
login_url = "http://tester:dslfjsdfblkhew%40122b1klbfw@testing.misleplav.ru/authorization/login/"
Expand Down
2 changes: 1 addition & 1 deletion pytest.ini
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[pytest]

addopts = -s -vv -m "not slow" --alluredir=allure-results --video on --screenshot on --headed
addopts = -s -vv -m "not slow" --alluredir=allure-results --video on --screenshot on

#addopts = -s -vv -m "not slow" --alluredir=allure-results --video on --screenshot on --headed --slowmo=3000
#for headed UI
Expand Down
7 changes: 4 additions & 3 deletions tests/test_find_tutor.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@

fake = Faker()

import time

@allure.title("TC_05.001.006.002")
@allure.link("https://github.com/RedRoverSchool/BookClubQA_Python_2024_fall/issues/243")
Expand Down Expand Up @@ -46,7 +45,7 @@ def test_verify_tutors_after_entered_min_experience(find_tutor):
find_tutor.enter_min_experience(min_experience)
find_tutor.click_filter_button()
find_tutor.check_experience_over_min_value(min_experience)
find_tutor.check_prices_over_min_price(0)


@allure.title("TC_34.001.001.002")
@allure.link("https://github.com/RedRoverSchool/BookClubQA_Python_2024_fall/issues/11")
Expand All @@ -56,14 +55,16 @@ def test_btn_more_find_tutor_is_visible(login, header, find_tutor):
login.full_login("acc.python.test@gmail.com", "jUvJ5ZSxzdIr")
find_tutor.check_btn_more_is_visible()


@allure.title("TC_34.001.001.003")
@allure.link("https://github.com/RedRoverSchool/BookClubQA_Python_2024_fall/issues/11")
# TC_34.001.001.003 [Student] Find a teacher > Verify button "Подробнее" in a tutor profile clickable and redirectible
# TC_34.001.001.003 [Student] Find a teacher > Verify button "Подробнее" in a tutor profile clickable and redirectible
def test_btn_more_find_tutor_is_clickable(login, header, find_tutor):
header.visit()
login.full_login("acc.python.test@gmail.com", "jUvJ5ZSxzdIr")
find_tutor.check_btn_more_is_clickable()


@allure.title("TC_34.001.001.004")
@allure.link("https://github.com/RedRoverSchool/BookClubQA_Python_2024_fall/issues/11")
# TC_34.001.001.004 [Student] Find a teacher > Verify button "Подробнее" has each tutor profile
Expand Down
11 changes: 5 additions & 6 deletions tests/test_header.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
from core.settings import pages_urls_for_guest
from core.settings import site_pages_urls
from playwright.sync_api import Page
import time


def test_login_button_opens_login_page(header, login):
Expand Down Expand Up @@ -252,30 +251,30 @@ def test_profile_btn_redirection(header, user_profile, login, data, page: Page):
header.click_profile_button()
user_profile.profile_btn_redirection_check()


# TC_31.003.001.001 | [Student ] Header > My Tutor(button) > Visibility check #326
def test_my_tutor_btn_visibility_as_student(login, header):
header.visit()
header.click_login_button()
login.full_login("acc.python.test@gmail.com", "jUvJ5ZSxzdIr")
header.student_my_tutors_button_is_visible()


# TC_31.003.001.003 | [Student ] Header > My Tutor(button) > Visibility check #326
def test_my_tutor_btn_clickable_redirection_as_student(login, header):
header.visit()
header.click_login_button()
login.full_login("acc.python.test@gmail.com", "jUvJ5ZSxzdIr")
header.student_my_tutors_button_clickable_redirect()


# TC_31.004.001.001 | [Student ] Header > Find Teacher(button) > Visibility check #321
def test_find_tutor_btn_visibility_as_student(login, header):
header.visit()
header.click_login_button()
login.full_login("acc.python.test@gmail.com", "jUvJ5ZSxzdIr")
header.student_find_tutor_button_is_visible()


# TC_31.004.001.003 | [Student ] Header > Find Teacher(button) > Visibility check #321
def test_find_tutor_btn_clickable_redirection_as_student(login, header):
header.visit()
header.click_login_button()
login.full_login("acc.python.test@gmail.com", "jUvJ5ZSxzdIr")
header.student_find_tutor_button_clickable_redirect()
header.student_find_tutor_button_clickable_redirect()
2 changes: 1 addition & 1 deletion tests/test_login.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ def test_login_as_tutor_btn_create_listing(header, login):
header.click_login_button()
login.enter_username("test_auth_login")
login.enter_password("test_auth_pass")
login.click_login_button()
login.click_submit_button()


@allure.title("TC_03.001.005")
Expand Down
Loading