-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Primeiro commit do Projeto de Testes Funcionais Automatizados Web em …
…Robot Framework desenvolvido para a squad Black List do Qa.Coders Academy
- Loading branch information
0 parents
commit f23e0e7
Showing
12 changed files
with
321 additions
and
0 deletions.
There are no files selected for viewing
45 changes: 45 additions & 0 deletions
45
.github/workflows/workflow-blacklist-academy-front-robot-selenium-requests.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
name: Pipeline Testes Automatizados Web Front ERP Qa.Coders Academy Robot Framework | ||
# executa o workflow toda vez que for realizado um push ou pull-request no repositório | ||
on: | ||
push: | ||
branches: [ "main" ] | ||
pull_request: | ||
branches: [ "main" ] | ||
|
||
# permite também executar esse workflow manualmente na aba "Actions" do GitHub | ||
workflow_dispatch: | ||
|
||
jobs: | ||
robot-web-chrome: | ||
# agente de execução/runner | ||
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.USUARIO_ENV", para os fixtures "usuario.json", etc | ||
run: | | ||
echo '${{ secrets.USUARIO_ENV }}' > ./resources/fixtures/usuario.json | ||
- name: Passo 3 - Instalar python versão 3.8 | ||
uses: actions/setup-python@v2 | ||
with: | ||
python-version: '3.8' | ||
|
||
- name: Passo 4 - Instalar dependências do projeto | ||
run: | | ||
pip install -r requirements.txt | ||
- name: Passo 5 - Executar testes automatizados Web no navegador chrome em modo headless (2º plano) no ambiente de automação e Gerar reports html, xml e screenshots | ||
run: robot -d ./reports -v BROWSER:headlesschrome ./tests/* | ||
|
||
- name: Passo 6 - Armazenar reports html, xml e screenshots | ||
uses: actions/upload-artifact@v3 | ||
# expressão condicional para que sempre seja executado independentemente dos resultados dos steps anteriores | ||
if: ${{ always() }} | ||
with: | ||
name: robot-web-reports-html-xml-screenshots-chrome | ||
path: ./reports | ||
# armazena por 30 dias | ||
retention-days: 30 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
__pycache__ | ||
*.xml | ||
*.html | ||
*.png | ||
*.log | ||
resources/fixtures/*.json | ||
!resources/fixtures/*.example.json |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
--- | ||
# Projeto de Testes Funcionais Automatizados Web | Robot Framework | SeleniumLibrary | RequestsLibrary | Python :test_tube: | ||
--- | ||
# :information_source: Introdução | ||
Esse projeto "blacklist-academy-front-robot" é executado no ambiente de automação do ["front"](https://automacao.qacoders.dev.br) e no ambiente da squad "black-list" da ["API REST"](https://black-list.qacoders.dev.br) do "ERP do Qa.Coders Academy" no navegador Chrome e Sistemas Operacionais Windows e Linux Ubuntu, com o objetivo de praticarmos ainda mais testes funcionais automatizados web em Robot Framework, SeleniumLibrary, RequestsLibrary, Python e GitHub Actions. | ||
|
||
|
||
--- |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
[^.]* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
robotframework==6.1.1 | ||
robotframework-pythonlibcore==4.3.0 | ||
robotframework-seleniumlibrary==6.2.0 | ||
selenium==4.16.0 | ||
robotframework-requests==1.0a10 | ||
requests==2.31.0 | ||
python-dateutil==2.9.0.post0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,128 @@ | ||
*** Settings *** | ||
Documentation Arquivo base com inicializações | ||
Library SeleniumLibrary | ||
Library RequestsLibrary | ||
Library helpers.py | ||
Resource env.resource | ||
Variables environments/${ENV}.json | ||
|
||
|
||
*** Variables *** | ||
${URL} ${base_url} | ||
${URI} ${base_uri} | ||
${BROWSER_CHROME} chrome | ||
${BROWSER_FIREFOX} firefox | ||
${HEADLESS_CHROME} headlesschrome | ||
${HEADLESS_FIREFOX} headlessfirefox | ||
${TIMEOUT} 3 | ||
|
||
|
||
*** Keywords *** | ||
Criar sessão front | ||
IF '${BROWSER}' == 'headlesschrome' | ||
Open Browser ${URL} ${HEADLESS_CHROME} | ||
ELSE IF '${BROWSER}' == 'headlessfirefox' | ||
Open Browser ${URL} ${HEADLESS_FIREFOX} | ||
ELSE IF '${BROWSER}' == 'firefox' | ||
Open Browser ${URL} ${BROWSER_FIREFOX} | ||
ELSE | ||
Open Browser ${URL} ${BROWSER_CHROME} | ||
END | ||
|
||
Set Window Size 1280 720 | ||
|
||
Criar sessão api | ||
${headers} Create Dictionary Content-Type=application/json | ||
Create Session alias=APIBlackList url=${URI} headers=${headers} disable_warnings=1 | ||
|
||
Encerrar sessão | ||
Capture Page Screenshot | ||
Close Browser | ||
|
||
Carregar usuario fixture | ||
${usuario_fixture} Carregar Fixture usuario | ||
Set Test Variable ${USUARIO_FIXTURE} ${usuario_fixture} | ||
|
||
Obter email usuario sysadmin estático | ||
Set Test Variable ${EMAIL_SYSADMIN} ${USUARIO_FIXTURE['sysadmin_valido']['email_valido']} | ||
|
||
Obter senha usuario sysadmin estático | ||
Set Test Variable ${SENHA} ${USUARIO_FIXTURE['sysadmin_valido']['senha_valida']} | ||
|
||
Obter dados usuario sydadmin estático | ||
Carregar usuario fixture | ||
Obter email usuario sysadmin estático | ||
Obter senha usuario sysadmin estático | ||
|
||
POST login (SYSADMIN) e obter token | ||
[Arguments] ${email} ${senha} | ||
${body} Create Dictionary | ||
... mail=${email} | ||
... password=${senha} | ||
Log ${body} | ||
|
||
Criar sessão api | ||
|
||
${response_post_login_sysadmin} POST On Session | ||
... alias=APIBlackList | ||
... url=/api/login | ||
... json=${body} | ||
... expected_status=200 | ||
|
||
Set Local Variable ${JSON_DATA_POST_LOGIN_SYSADMIN} ${response_post_login_sysadmin.json()} | ||
Set Test Variable ${TOKEN_SYSADMIN} ${JSON_DATA_POST_LOGIN_SYSADMIN['token']} | ||
|
||
Gerar nome completo usuario admin dinâmico | ||
${nome_completo} Gerar Nome Completo | ||
Set Test Variable ${NOME_COMPLETO} ${nome_completo} | ||
|
||
Gerar email usuario admin dinâmico | ||
${email_admin} Gerar email usuario | ||
Set Test Variable ${EMAIL_ADMIN} ${email_admin} | ||
|
||
Gerar cpf usuario admin dinâmico | ||
${cpf} Gerar Cpf | ||
Set Test Variable ${CPF} ${cpf} | ||
|
||
Obter senha e confirme a senha estáticas usuario admin dinâmico | ||
Set Test Variable ${SENHA_CONFIRME_A_SENHA} ${USUARIO_FIXTURE['admin_valido']['senha_confirme_a_senha_validas']} | ||
|
||
POST usuario (ADMIN) e obter email | ||
[Arguments] ${nome_completo} ${email} ${cpf} ${senha_confirme_a_senha} | ||
${body} Create Dictionary | ||
... fullName=${nome_completo} | ||
... mail=${email} | ||
... accessProfile=ADMIN | ||
... cpf=${cpf} | ||
... password=${senha_confirme_a_senha} | ||
... confirmPassword=${senha_confirme_a_senha} | ||
Log ${body} | ||
|
||
Criar sessão api | ||
|
||
${headers} Create Dictionary Authorization=${TOKEN_SYSADMIN} | ||
|
||
${response_post_user_admin} POST On Session | ||
... alias=APIBlackList | ||
... url=/api/user | ||
... headers=${headers} | ||
... json=${body} | ||
... expected_status=201 | ||
|
||
Set Local Variable ${JSON_DATA_POST_USER_ADMIN} ${response_post_user_admin.json()} | ||
Set Test Variable ${EMAIL_ADMIN} ${JSON_DATA_POST_USER_ADMIN['user']['mail']} | ||
|
||
Gerar e obter dados usuario admin dinâmico | ||
Obter dados usuario sydadmin estático | ||
POST login (SYSADMIN) e obter token email=${EMAIL_SYSADMIN} senha=${SENHA} | ||
Gerar nome completo usuario admin dinâmico | ||
Gerar email usuario admin dinâmico | ||
Gerar cpf usuario admin dinâmico | ||
Carregar usuario fixture | ||
Obter senha e confirme a senha estáticas usuario admin dinâmico | ||
POST usuario (ADMIN) e obter email | ||
... nome_completo=${NOME_COMPLETO} | ||
... email=${EMAIL_ADMIN} | ||
... cpf=${CPF} | ||
... senha_confirme_a_senha=${SENHA_CONFIRME_A_SENHA} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
*** Settings *** | ||
Documentation Arquivo com variáveis globais de ambiente e navegador padrão | ||
|
||
*** Variables *** | ||
${ENV} automacao | ||
${BROWSER} chrome |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
{ | ||
"base_url": "https://automacao.qacoders.dev.br", | ||
"base_uri": "https://black-list.qacoders.dev.br" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
{ | ||
"sysadmin_valido": { | ||
"email_valido": "informar-email-usuario-sysadmin-valido", | ||
"senha_valida": "informar-password-usuario-sysadmin-valido" | ||
}, | ||
"admin_valido": { | ||
"senha_confirme_a_senha_validas": "informar-senha-confirme-a-senha-usuario-admin-valido" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
import random, json | ||
|
||
def gerar_numeros_aleatorios(qtde_numeros): | ||
possible = "0123456789" | ||
text = ''.join(random.choice(possible) for _ in range(qtde_numeros)) | ||
|
||
return text | ||
|
||
def mod(dividendo, divisor): | ||
return round(dividendo - (dividendo // divisor) * divisor) | ||
|
||
def gerar_cpf(): | ||
rnd = lambda n: round(random.random() * n) | ||
n = [rnd(9) for _ in range(9)] | ||
|
||
d1 = 11 - mod(sum([n[i] * (10 - i) for i in range(9)]), 11) | ||
d1 = 0 if d1 >= 10 else d1 | ||
|
||
d2 = 11 - mod(d1 * 2 + sum([n[i] * (11 - i) for i in range(9)]), 11) | ||
d2 = 0 if d2 >= 10 else d2 | ||
|
||
return f"{''.join(map(str, n))}{d1}{d2}" | ||
|
||
def gerar_nome_completo(): | ||
nome_completo = "ADMIN Blacklist" | ||
|
||
return nome_completo | ||
|
||
def gerar_email_usuario(): | ||
email = "admin.blacklist" + gerar_numeros_aleatorios(6) + "@qacoders.com" | ||
|
||
return email | ||
|
||
def carregar_fixture(nome_fixture): | ||
with open(f'resources/fixtures/{nome_fixture}.json', 'r', encoding='utf-8') as fixture: | ||
return json.load(fixture) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
*** Settings *** | ||
Documentation Arquivo com variáveis locais e palavras-chave da funcionalidade de login | ||
Resource ../../resources/base.resource | ||
|
||
|
||
*** Variables *** | ||
${campo_email} id=email | ||
${campo_senha} css=input[name="password"] | ||
${botao_entrar} css=button[type="submit"] | ||
|
||
|
||
*** Keywords *** | ||
Acessar a tela de Login do ERP do Qa.Coders Academy | ||
Criar sessão front | ||
Go To ${URL}/login | ||
|
||
Informar os campos de email e senha de um usuário SYSADMIN | ||
[Arguments] ${email} ${senha} | ||
Wait Until Element Is Visible ${campo_email} | ||
Click Element ${campo_email} | ||
Input Text ${campo_email} ${email} | ||
|
||
Wait Until Element Is Visible ${campo_senha} | ||
Click Element ${campo_senha} | ||
Input Text ${campo_senha} ${senha} | ||
|
||
Informar os campos de email e senha de um usuário ADMIN | ||
[Arguments] ${email_admin} ${senha_admin} | ||
Wait Until Element Is Visible ${campo_email} | ||
Click Element ${campo_email} | ||
Input Text ${campo_email} ${email_admin} | ||
|
||
Wait Until Element Is Visible ${campo_senha} | ||
Click Element ${campo_senha} | ||
Input Text ${campo_senha} ${senha_admin} | ||
|
||
Clicar no botão "ENTRAR" | ||
Wait Until Element Is Visible ${botao_entrar} | ||
Click Element ${botao_entrar} | ||
|
||
Apresentar a tela Home | ||
Sleep ${TIMEOUT} | ||
Location Should Be ${URL}/home |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
*** Settings *** | ||
Documentation Arquivo com os casos de testes da funcionalidade de login | ||
Resource ../resources/base.resource | ||
Resource ../resources/keywords/login_keyword.robot | ||
|
||
Test Teardown Encerrar sessão | ||
|
||
|
||
*** Test Cases *** | ||
Login (SYSADMIN) - Email e Senha (corretos) - Validar apresentar a tela Home | ||
[Tags] login_sysadmin regressao | ||
Acessar a tela de Login do ERP do Qa.Coders Academy | ||
Obter dados usuario sydadmin estático | ||
Informar os campos de email e senha de um usuário SYSADMIN email=${EMAIL_SYSADMIN} senha=${SENHA} | ||
Clicar no botão "ENTRAR" | ||
Apresentar a tela Home | ||
|
||
Login (ADMIN) - Email e Senha (corretos) - Validar apresentar a tela Home | ||
[Tags] login_admin regressao | ||
Acessar a tela de Login do ERP do Qa.Coders Academy | ||
Gerar e obter dados usuario admin dinâmico | ||
Informar os campos de email e senha de um usuário ADMIN email_admin=${EMAIL_ADMIN} senha_admin=${SENHA_CONFIRME_A_SENHA} | ||
Clicar no botão "ENTRAR" | ||
Apresentar a tela Home |