Skip to content

TestLogin

Модуль тестов авторизации.

Содержит тесты для проверки функционала входа и выхода из системы.

TestLogin

Класс тестов для проверки авторизации.

Тесты покрывают следующие сценарии: 1. test_successful_login: Проверяет успешный вход в систему 2. test_unsuccessful_login: Проверяет вход с неверными учетными данными 3. test_successful_login_and_logout: Проверяет успешный вход и выход из системы 4. test_password_visibility: Проверяет видимость символов пароля

Source code in tests\e2e\test_login.py
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
class TestLogin:
    """Класс тестов для проверки авторизации.

    Тесты покрывают следующие сценарии:
    1. test_successful_login: Проверяет успешный вход в систему
    2. test_unsuccessful_login: Проверяет вход с неверными учетными данными
    3. test_successful_login_and_logout: Проверяет успешный вход и выход из системы
    4. test_password_visibility: Проверяет видимость символов пароля
    """

    # @pytest.mark.develop
    def test_successful_login(self, browser: Page) -> None:
        """Проверяет успешный вход в систему.

        Args:
            browser: Экземпляр страницы Playwright.
        """

        lp = LoginPage(browser)
        lp.do_login()

    def test_unsuccessful_login(self, browser: Page) -> None:
        """Проверяет вход с неверными учетными данными.

        Args:
            browser: Экземпляр страницы Playwright.
        """

        lp = LoginPage(browser)
        lp.do_unsuccessful_login()

    # @pytest.mark.develop
    def test_successful_login_and_logout(self, browser: Page) -> None:
        """Проверяет успешный вход и выход из системы.

        Args:
            browser: Экземпляр страницы Playwright.
        """

        lp = LoginPage(browser)
        lp.do_login()

        mp = MainPage(browser)
        mp.do_logout()

    def test_password_visibility(self, browser: Page) -> None:
        """Проверяет видимость символов пароля.

        Args:
            browser: Экземпляр страницы Playwright.
        """

        lp = LoginPage(browser)
        lp.open("")

        is_hidden_icon = lp.is_password_icon_hidden()

        if is_hidden_icon:
            is_hidden = lp.is_password_hidden()
            assert is_hidden, "Password should be hidden"

            # Нажатие на иконку скрытия пароля, пароль видим
            lp.click_password_hidden_icon()
            is_hidden_icon = lp.is_password_icon_hidden()
            is_hidden = lp.is_password_hidden()

            assert not is_hidden_icon, "Password hidden icon should not be in hidden state"
            assert not is_hidden, "Password should be visible"
        else:
            is_hidden = lp.is_password_hidden()
            assert not is_hidden, "Password should be visible"

            # Нажатие на иконку скрытия пароля, пароль скрыт
            lp.click_password_hidden_icon()
            is_hidden_icon = lp.is_password_icon_hidden()
            is_hidden = lp.is_password_hidden()

            assert is_hidden_icon, "Password hidden icon should be in hidden state"
            assert is_hidden, "Password should be hidden"

test_password_visibility(browser)

Проверяет видимость символов пароля.

Parameters:

Name Type Description Default
browser Page

Экземпляр страницы Playwright.

required
Source code in tests\e2e\test_login.py
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
def test_password_visibility(self, browser: Page) -> None:
    """Проверяет видимость символов пароля.

    Args:
        browser: Экземпляр страницы Playwright.
    """

    lp = LoginPage(browser)
    lp.open("")

    is_hidden_icon = lp.is_password_icon_hidden()

    if is_hidden_icon:
        is_hidden = lp.is_password_hidden()
        assert is_hidden, "Password should be hidden"

        # Нажатие на иконку скрытия пароля, пароль видим
        lp.click_password_hidden_icon()
        is_hidden_icon = lp.is_password_icon_hidden()
        is_hidden = lp.is_password_hidden()

        assert not is_hidden_icon, "Password hidden icon should not be in hidden state"
        assert not is_hidden, "Password should be visible"
    else:
        is_hidden = lp.is_password_hidden()
        assert not is_hidden, "Password should be visible"

        # Нажатие на иконку скрытия пароля, пароль скрыт
        lp.click_password_hidden_icon()
        is_hidden_icon = lp.is_password_icon_hidden()
        is_hidden = lp.is_password_hidden()

        assert is_hidden_icon, "Password hidden icon should be in hidden state"
        assert is_hidden, "Password should be hidden"

test_successful_login(browser)

Проверяет успешный вход в систему.

Parameters:

Name Type Description Default
browser Page

Экземпляр страницы Playwright.

required
Source code in tests\e2e\test_login.py
24
25
26
27
28
29
30
31
32
def test_successful_login(self, browser: Page) -> None:
    """Проверяет успешный вход в систему.

    Args:
        browser: Экземпляр страницы Playwright.
    """

    lp = LoginPage(browser)
    lp.do_login()

test_successful_login_and_logout(browser)

Проверяет успешный вход и выход из системы.

Parameters:

Name Type Description Default
browser Page

Экземпляр страницы Playwright.

required
Source code in tests\e2e\test_login.py
45
46
47
48
49
50
51
52
53
54
55
56
def test_successful_login_and_logout(self, browser: Page) -> None:
    """Проверяет успешный вход и выход из системы.

    Args:
        browser: Экземпляр страницы Playwright.
    """

    lp = LoginPage(browser)
    lp.do_login()

    mp = MainPage(browser)
    mp.do_logout()

test_unsuccessful_login(browser)

Проверяет вход с неверными учетными данными.

Parameters:

Name Type Description Default
browser Page

Экземпляр страницы Playwright.

required
Source code in tests\e2e\test_login.py
34
35
36
37
38
39
40
41
42
def test_unsuccessful_login(self, browser: Page) -> None:
    """Проверяет вход с неверными учетными данными.

    Args:
        browser: Экземпляр страницы Playwright.
    """

    lp = LoginPage(browser)
    lp.do_unsuccessful_login()