Files

116 lines
3.8 KiB
Markdown
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

---
id: 5f8884f4c46685731aabfc41
title: Запуск функціональних тестів за допомогою Headless Browser II
challengeType: 2
forumTopicId: 301594
dashedName: run-functional-tests-using-a-headless-browser-ii
---
# --description--
Нагадуємо, що цей проєкт створюється на основі початкового проєкту на [ Replit](https://replit.com/github/freeCodeCamp/boilerplate-mochachai) або копіюється з [ GitHub](https://github.com/freeCodeCamp/boilerplate-mochachai/).
# --instructions--
У межах `tests/2_functional-tests.js` у тесті `'Submit the surname "Vespucci" in the HTML form'` (`// #5`) потрібно автоматизувати такі умови:
1. Впишіть у форму прізвище `Vespucci`
2. Натисніть кнопку підтвердження
У межах кнопки зворотного виклику `pressButton`:
1. Підтвердьте, що статус OK `200`
2. Підтвердьте, що текст всередині елемента `span#name` це `'Amerigo'`
3. Підтвердьте, що текст всередині елемента `span#surname` це `'Vespucci'`
4. Підтвердьте, що елемент(и) `span#dates` існують і їхній підрахунок дорівнює `1`
Не забудьте видалити виклик `assert.fail()`.
# --hints--
Необхідно пройти всі тести.
```js
(getUserInput) =>
$.get(getUserInput('url') + '/_api/get-tests?type=functional&n=6').then(
(data) => {
assert.equal(data.state, 'passed');
},
(xhr) => {
throw new Error(xhr.responseText);
}
);
```
Вам слід підтвердити, що запит безголового браузера був успішним.
```js
(getUserInput) =>
$.get(getUserInput('url') + '/_api/get-tests?type=functional&n=6').then(
(data) => {
assert.equal(data.assertions[0].method, 'browser.success');
},
(xhr) => {
throw new Error(xhr.responseText);
}
);
```
Підтвердьте, що текст всередині елемента `span#name`> це `'Amerigo'`.
```js
(getUserInput) =>
$.get(getUserInput('url') + '/_api/get-tests?type=functional&n=6').then(
(data) => {
assert.equal(data.assertions[1].method, 'browser.text');
assert.match(data.assertions[1].args[0], /('|")span#name\1/);
assert.match(data.assertions[1].args[1], /('|")Amerigo\1/);
},
(xhr) => {
throw new Error(xhr.responseText);
}
);
```
Підтвердьте, що текст всередині елемента `span#surname` це `'Vespucci'`.
```js
(getUserInput) =>
$.get(getUserInput('url') + '/_api/get-tests?type=functional&n=6').then(
(data) => {
assert.equal(data.assertions[2].method, 'browser.text');
assert.match(data.assertions[2].args[0], /('|")span#surname\1/);
assert.match(data.assertions[2].args[1], /('|")Vespucci\1/);
},
(xhr) => {
throw new Error(xhr.responseText);
}
);
```
Підтвердьте, що елемент `span#dates` існує, а його підрахунок - 1.
```js
(getUserInput) =>
$.get(getUserInput('url') + '/_api/get-tests?type=functional&n=6').then(
(data) => {
assert.equal(data.assertions[3].method, 'browser.elements');
assert.match(data.assertions[3].args[0], /('|")span#dates\1/);
assert.equal(data.assertions[3].args[1], 1);
},
(xhr) => {
throw new Error(xhr.responseText);
}
);
```
# --solutions--
```js
/**
Backend challenges don't need solutions,
because they would need to be tested against a full working project.
Please check our contributing guidelines to learn more.
*/
```