Powrót do: Praktyczne wprowadzenie do testów automatycznych z Playwright
Rozwiązanie – adnotacje i tagi
TIP: Ta lekcja jest częścią rozwijanego Programu Testy Automatyczne z Playwright 🎭
Dodatkowe materiały
Rozwiązanie prezentowane w tej lekcji zajdziesz w naszym repozytorium: L06_rozwiazanie_adnotacje
Zmodyfikowane testy w pliku login.spec.ts:
test(
'unsuccessful login with too short username',
{ tag: ['@login', '@unhappy-path'] },
async ({ page }) => {
// Arrange
const incorrectUserId = 'tester';
const expectedErrorMessage = 'identyfikator ma min. 8 znaków';
// Act
await loginPage.loginInput.fill(incorrectUserId);
await loginPage.passwordInput.click();
// Assert
await expect(loginPage.loginError).toHaveText(expectedErrorMessage);
}
);
test(
'unsuccessful login with too short password',
{ tag: ['@login', '@unhappy-path'] },
async ({ page }) => {
// Arrange
const userId = loginData.userId;
const incorrectPassword = '1234';
const expectedErrorMessage = 'hasło ma min. 8 znaków';
// Act
await loginPage.loginInput.fill(userId);
await loginPage.passwordInput.fill(incorrectPassword);
await loginPage.passwordInput.blur();
// Assert
await expect(loginPage.passwordError).toHaveText(expectedErrorMessage);
}
);
Zmodyfikowany test w pliku pulpit.spec.ts:
test(
'quick payment with correct data',
{
tag: ['@integration', '@pulpit'],
annotation: {
type: 'documentation',
description: 'https://jaktestowac.pl/course/playwright-wprowadzenie/',
},
},
async ({ page }) => {
// Arrange
const receiverId = '2';
const transferAmount = '150';
const transferTitle = 'pizza';
const expectedTransferReceiver = 'Chuck Demobankowy';
// Act
await pulpitPage.executeQuickPayment(
receiverId,
transferAmount,
transferTitle
);
// Assert
await expect(pulpitPage.messageText).toHaveText(
`Przelew wykonany! ${expectedTransferReceiver} - ${transferAmount},00PLN - ${transferTitle}`
);
}
);
