diff --git a/.github/workflows/workflow-testes-automatizados-web-front-serve-rest-playwright.yml b/.github/workflows/workflow-testes-automatizados-web-front-serve-rest-playwright.yml index 447160b..b617f59 100644 --- a/.github/workflows/workflow-testes-automatizados-web-front-serve-rest-playwright.yml +++ b/.github/workflows/workflow-testes-automatizados-web-front-serve-rest-playwright.yml @@ -11,7 +11,7 @@ on: workflow_dispatch: jobs: - testes-automatizados-web-front-serve-rest-playwright-chrome: + playwright-chrome: # agente de execução/runner do tipo máquina virtual bem enxuta, sem interface gráfica runs-on: ubuntu-latest steps: @@ -55,3 +55,46 @@ jobs: name: playwright-relatorio-html-chrome path: ./playwright-report retention-days: 30 + + playwright-firefox: + # esse job "playwright-firefox" somente é executado se o job anterior "playwright-chrome" for executado com sucesso + needs: playwright-chrome + runs-on: ubuntu-latest + steps: + - name: Passo 1 - Obter cópia do código-fonte do repositório + uses: actions/checkout@v3 + + - name: Passo 2 - Redirecionar os conteúdos de "secrets.LOGIN_ENV", "secrets.USUARIO_ENV", para os arquivos "login.json", "usuario.json", etc + run: | + echo '${{ secrets.LOGIN_ENV }}' > ./tests/support/fixtures/login.json + echo '${{ secrets.USUARIO_ENV }}' > ./tests/support/fixtures/usuario.json + + - name: Passo 3 - Instalar node versão 18 + uses: actions/setup-node@v3 + with: + node-version: 18 + + - name: Passo 4 - Instalar dependências do projeto + run: npm install --force + + - name: Passo 5 - Instalar navegadores do Playwright + run: npx playwright install --with-deps + + - name: Passo 6 - Executar testes em modo headless (2º plano) em um ambiente de produção e Gerar os resultados dos testes + run: npm run test:ff + + - name: Passo 7 - Armazenar os resultados dos testes em screenshots e vídeos + uses: actions/upload-artifact@v3 + if: ${{ always() }} + with: + name: playwright-screenshots-videos-firefox + path: ./test-results + retention-days: 30 + + - name: Passo 8 - Armazenar os resultados dos testes em relatório html + uses: actions/upload-artifact@v3 + if: ${{ always() }} + with: + name: playwright-relatorio-html-firefox + path: ./playwright-report + retention-days: 30 \ No newline at end of file diff --git a/README.md b/README.md index ba79f1d..d7b0ab0 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,7 @@ # Projeto de Testes Automatizados Web | Playwright | Javascript | Page Objects | GitHub Actions :test_tube: --- # :information_source: Introdução -Me baseei e adaptei parte do que foi ensinado nos cursos ["Playwright eXpress"](https://www.udemy.com/course/playwright-express) e ["Playwright Zombie Edition"](https://www.udemy.com/course/playwright-zombie) da ["QAx"](https://www.udemy.com/user/weare-qax) para esse projeto "testes-automatizados-web-front-serve-rest_playwright-javascript" que é executado em um ambiente de produção no ["front"](https://front.serverest.dev) e na ["API REST"](https://serverest.dev) do ["ServeRest"](https://github.com/ServeRest) que simula uma loja virtual, e que foi desenvolvido com o objetivo de me aprofundar um pouco mais nos estudos sobre testes automatizados web em Playwright, Javascript, Page Objects e GitHub Actions. +Me baseei e adaptei parte do que foi ensinado nos cursos ["Playwright eXpress"](https://www.udemy.com/course/playwright-express) e ["Playwright Zombie Edition"](https://www.udemy.com/course/playwright-zombie) da ["QAx"](https://www.udemy.com/user/weare-qax) para esse projeto "testes-automatizados-web-front-serve-rest_playwright-javascript" que é executado em um ambiente de produção no ["front"](https://front.serverest.dev) e na ["API REST"](https://serverest.dev) do ["ServeRest"](https://github.com/ServeRest) que simula uma loja virtual, nos navegadores Chrome e Firefox, Sistemas Operacionais Windows e Linux Ubuntu, e que foi desenvolvido com o objetivo de me aprofundar um pouco mais nos estudos sobre testes automatizados web em Playwright, Javascript, Page Objects e GitHub Actions. --- diff --git a/package.json b/package.json index 39c816d..e82b114 100644 --- a/package.json +++ b/package.json @@ -7,9 +7,13 @@ "pw:ui": "playwright test --ui", "pw:ui:local": "ENV environment=local playwright test --ui", "test": "playwright test --project=chromium", + "test:ff": "playwright test --project=firefox", "test:local": "ENV environment=local playwright test --project=chromium", + "test:local:ff": "ENV environment=local playwright test --project=firefox", "test:headed": "playwright test --project=chromium --headed", - "test:local:headed": "ENV environment=local playwright test --project=chromium --headed" + "test:headed:ff": "playwright test --project=firefox --headed", + "test:local:headed": "ENV environment=local playwright test --project=chromium --headed", + "test:local:headed:ff": "ENV environment=local playwright test --project=firefox --headed" }, "author": "Andressa Karla", "license": "ISC", diff --git a/playwright.config.js b/playwright.config.js index a754ccf..5873c3f 100644 --- a/playwright.config.js +++ b/playwright.config.js @@ -41,6 +41,13 @@ module.exports = defineConfig({ ...devices['Desktop Chrome'], baseURL: baseURLFront }, + }, + { + name: 'firefox', + use: { + ...devices['Desktop Firefox'], + baseURL: baseURLFront + }, } ] }) diff --git a/tests/pages/home-page.js b/tests/pages/home-page.js index e62073c..7fb43c0 100644 --- a/tests/pages/home-page.js +++ b/tests/pages/home-page.js @@ -1,8 +1,8 @@ class HomePage { constructor(page) { this.page = page; - this.textoBemVindo = page.locator('#root > div > div > h1') - this.textoSistemaAdministrarEcommerce = page.locator('#root > div > div > p.lead') + this.textoBemVindo = page.locator('h1') + this.textoSistemaAdministrarEcommerce = page.locator('p.lead') } }