147 lines
6.6 KiB
Markdown
147 lines
6.6 KiB
Markdown
# Test info
|
||
|
||
- Name: Позитивные сценарии регистрации >> Успешная регистрация нового пользователя
|
||
- Location: /Users/vladsmykov/Desktop/Work/AUTOTESTS/CCPC_playwright/tests/ui/registration/register.spec.ts:6:7
|
||
|
||
# Error details
|
||
|
||
```
|
||
Error: locator.fill: Target page, context or browser has been closed
|
||
Call log:
|
||
- waiting for getByPlaceholder('Учёное звание*')
|
||
- locator resolved to <input readonly value="" type="text" class=" false " name="academicTitle" autocomplete="new-password" placeholder="Учёное звание*"/>
|
||
- fill("Доцент")
|
||
- attempting fill action
|
||
2 × waiting for element to be visible, enabled and editable
|
||
- element is not editable
|
||
- retrying fill action
|
||
- waiting 20ms
|
||
2 × waiting for element to be visible, enabled and editable
|
||
- element is not editable
|
||
- retrying fill action
|
||
- waiting 100ms
|
||
128 × waiting for element to be visible, enabled and editable
|
||
- element is not editable
|
||
- retrying fill action
|
||
- waiting 500ms
|
||
|
||
at RegisterPage.register (/Users/vladsmykov/Desktop/Work/AUTOTESTS/CCPC_playwright/page-objects/RegisterPage.ts:100:35)
|
||
at /Users/vladsmykov/Desktop/Work/AUTOTESTS/CCPC_playwright/tests/ui/registration/register.spec.ts:15:5
|
||
```
|
||
|
||
# Test source
|
||
|
||
```ts
|
||
1 | import { Page, Locator } from '@playwright/test';
|
||
2 |
|
||
3 | export class RegisterPage {
|
||
4 | readonly page: Page;
|
||
5 |
|
||
6 | // Поля ввода
|
||
7 | readonly nameInput: Locator;
|
||
8 | readonly surnameInput: Locator;
|
||
9 | readonly patronymicInput: Locator;
|
||
10 | readonly academicTitleInput: Locator;
|
||
11 | readonly degreeInput: Locator;
|
||
12 | readonly positionInput: Locator;
|
||
13 | readonly organizationInput: Locator;
|
||
14 | readonly emailInput: Locator;
|
||
15 | readonly phoneInput: Locator;
|
||
16 | readonly passwordInput: Locator;
|
||
17 | readonly confirmPasswordInput: Locator;
|
||
18 |
|
||
19 | // Глазики
|
||
20 | readonly passwordToggle: Locator;
|
||
21 | readonly confirmPasswordToggle: Locator;
|
||
22 |
|
||
23 | // Кнопка регистрации
|
||
24 | readonly submitButton: Locator;
|
||
25 |
|
||
26 | // Ссылка "Авторизируйтесь"
|
||
27 | readonly loginLink: Locator;
|
||
28 |
|
||
29 | // Ошибки валидации
|
||
30 | readonly requiredFieldErrors: Locator;
|
||
31 | readonly nameError: Locator;
|
||
32 | readonly surnameError: Locator;
|
||
33 | readonly positionError: Locator;
|
||
34 | readonly emailFormatError: Locator;
|
||
35 | readonly passwordLengthError: Locator;
|
||
36 | readonly confirmPasswordRequiredError: Locator;
|
||
37 |
|
||
38 | // Модалки
|
||
39 | readonly duplicateUserModal: Locator;
|
||
40 | readonly invalidOrgModal: Locator;
|
||
41 |
|
||
42 | constructor(page: Page) {
|
||
43 | this.page = page;
|
||
44 |
|
||
45 | // Инпуты
|
||
46 | this.nameInput = page.getByPlaceholder('Имя*');
|
||
47 | this.surnameInput = page.getByPlaceholder('Фамилия*');
|
||
48 | this.patronymicInput = page.getByPlaceholder('Отчество');
|
||
49 | this.academicTitleInput = page.getByPlaceholder('Учёное звание*');
|
||
50 | this.degreeInput = page.getByPlaceholder('Учёная степень*');
|
||
51 | this.positionInput = page.getByPlaceholder('Должность');
|
||
52 | this.organizationInput = page.getByPlaceholder('Организация*');
|
||
53 | this.emailInput = page.getByPlaceholder('Email (логин)*');
|
||
54 | this.phoneInput = page.getByPlaceholder('Номер телефона*');
|
||
55 | this.passwordInput = page.getByPlaceholder('Придумайте пароль*');
|
||
56 | this.confirmPasswordInput = page.getByPlaceholder('Повторите пароль*');
|
||
57 |
|
||
58 | // Глазики
|
||
59 | this.passwordToggle = page.locator('input[name="password"] + img');
|
||
60 | this.confirmPasswordToggle = page.locator('input[name="confirmPassword"] + img');
|
||
61 |
|
||
62 | // Кнопки
|
||
63 | this.submitButton = page.getByRole('button', { name: 'Зарегистрироваться' });
|
||
64 | this.loginLink = page.getByText('Авторизируйтесь');
|
||
65 |
|
||
66 | // Ошибки
|
||
67 | this.requiredFieldErrors = page.locator('div[name="error"]', { hasText: 'Поле обязательно для заполнения' });
|
||
68 | this.nameError = page.getByText('Некорректное имя');
|
||
69 | this.surnameError = page.getByText('Некорректная фамилия');
|
||
70 | this.positionError = page.getByText('Не более 200 символов!');
|
||
71 | this.emailFormatError = page.getByText('Некорректный Email');
|
||
72 | this.passwordLengthError = page.getByText('Не менее 8 символов');
|
||
73 | this.confirmPasswordRequiredError = page.getByText('Поле обязательно для заполнения');
|
||
74 |
|
||
75 | // Модальные окна
|
||
76 | this.duplicateUserModal = page.getByText('Пользователь с таким email или телефоном уже зарегистрирован!');
|
||
77 | this.invalidOrgModal = page.getByText('Некорректное название организации!');
|
||
78 | }
|
||
79 |
|
||
80 | async goto() {
|
||
81 | await this.page.goto('/login/registration');
|
||
82 | }
|
||
83 |
|
||
84 | async register(data: {
|
||
85 | name: string,
|
||
86 | surname: string,
|
||
87 | patronymic?: string,
|
||
88 | academicTitle: string,
|
||
89 | degree: string,
|
||
90 | position?: string,
|
||
91 | organization: string,
|
||
92 | email: string,
|
||
93 | phone: string,
|
||
94 | password: string,
|
||
95 | confirmPassword: string
|
||
96 | }) {
|
||
97 | await this.nameInput.fill(data.name);
|
||
98 | await this.surnameInput.fill(data.surname);
|
||
99 | if (data.patronymic) await this.patronymicInput.fill(data.patronymic);
|
||
> 100 | await this.academicTitleInput.fill(data.academicTitle);
|
||
| ^ Error: locator.fill: Target page, context or browser has been closed
|
||
101 | await this.degreeInput.fill(data.degree);
|
||
102 | if (data.position) await this.positionInput.fill(data.position);
|
||
103 | await this.organizationInput.fill(data.organization);
|
||
104 | await this.emailInput.fill(data.email);
|
||
105 | await this.phoneInput.fill(data.phone);
|
||
106 | await this.passwordInput.fill(data.password);
|
||
107 | await this.confirmPasswordInput.fill(data.confirmPassword);
|
||
108 | await this.submitButton.click();
|
||
109 | }
|
||
110 | }
|
||
111 |
|
||
``` |