Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Criação PageObject #4

Merged
merged 3 commits into from
May 14, 2024
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
35 changes: 35 additions & 0 deletions pages/perfil.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
const { expect } = require('@playwright/test');
const { PATH } = require('../utils/constants');

exports.PerfilPage = class PerfilPage {
constructor(page) {
this.page = page;
}

async goto() {
await this.page.goto(PATH.perfil);
}

async clicarExtenderBio() {
const extenderBioButton = "//button[contains(.,'Ver mais')]";
await this.page.click(extenderBioButton);
}

async clicarReduzirBio() {
const reduzirBioButton = "//button[contains(.,'Ver menos')]";
await this.page.click(reduzirBioButton);
}

async validarTitulo() {
await expect(this.page).toHaveTitle(/Tem Vaga Mestre/);
}

async validarEstilosPreferidos() {
const estilosPreferidos = "(//h1[contains(.,'Estilos preferidos')])[1]";
await expect(this.page.locator(estilosPreferidos)).toBeVisible();
}
async validarConquistas() {
const conquistas = "(//h1[contains(.,'Conquistas')])[1]";
await expect(this.page.locator(conquistas)).toBeVisible();
}
};
25 changes: 11 additions & 14 deletions tests/perfil.spec.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,12 @@
const { test, expect } = require('@playwright/test');
const { PATH } = require('../utils/constants');

test('acessar perfil', async ({ page }) => {
await page.goto(PATH.perfil);

await expect(page).toHaveTitle(/Tem Vaga Mestre/);

await expect(
page.getByRole('heading', { name: 'Estilos preferidos' })
).toBeVisible();
await expect(page.getByRole('heading', { name: 'Conquistas' })).toBeVisible();

await page.getByRole('button', { name: 'Ver mais' }).click();
const { test } = require('@playwright/test');
import { PerfilPage } from '../pages/perfil.js';

test('Acessar perfil', async ({ page }) => {
const perfilPage = new PerfilPage(page);
await perfilPage.goto();
await perfilPage.validarTitulo();
await perfilPage.clicarExtenderBio();
await perfilPage.clicarReduzirBio();
await perfilPage.validarEstilosPreferidos();
await perfilPage.validarConquistas();
});