Skip to content

Commit

Permalink
add .env file
Browse files Browse the repository at this point in the history
  • Loading branch information
Jmateusribeiro committed Aug 15, 2023
1 parent 88e18fc commit c236822
Show file tree
Hide file tree
Showing 15 changed files with 68 additions and 49 deletions.
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,9 @@ Note: Don't forget to run the bat file inside an environment with all requiremen
just the test that cover that feature will fail)
- Don't forget to cover the features of menu navigation :)

The .env file is committed because this project is only to demonstration purposes.
In real projects the .env file, containing critical info, must be add to .gitignore


Hope you enjoyed!

Expand Down
3 changes: 3 additions & 0 deletions credentials.env
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
eve.holt@reqres.in=QpwL5tke4Pnpja7X4
michael.lawson@reqres.in=QpwL5tke4Pnpja7X7
lindsay.ferguson@reqres.in=QpwL5tke4Pnpja7X8
3 changes: 2 additions & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@ robotframework
robotframework-datadriver
robotframework-requests
robotframework-seleniumlibrary
robotframework-pabot
robotframework-pabot
python-dotenv
16 changes: 15 additions & 1 deletion resources/config/config.resource
Original file line number Diff line number Diff line change
@@ -1,11 +1,25 @@
*** Settings ***
Documentation Config file
Library OperatingSystem
Library dotenv


*** Variables ***
${PROJECT_DIR} ${CURDIR}/../..

${BROWSER} chrome
${HEROKU_HOMEPAGE} https://the-internet.herokuapp.com/
${HEROKU_TABLES_PAGE} https://the-internet.herokuapp.com/tables

${API_HOST} https://reqres.in/
${REGISTRATION_ENDPOINT} api/register
${REGISTRATION_ENDPOINT} api/register


*** Keywords ***
Load Environment Variables
[Documentation] Load environment variables from a .env file
File Should Exist ${PROJECT_DIR}/credentials.env
... msg=The file 'credentials.env' was not found in the root dir of the project

Load Dotenv ${PROJECT_DIR}/credentials.env
11 changes: 5 additions & 6 deletions resources/pages/base_page.resource
Original file line number Diff line number Diff line change
@@ -1,19 +1,18 @@
*** Settings ***
Documentation base page
Documentation Base page
Library SeleniumLibrary
Library Collections
Library SeleniumLibrary
Resource resources/config/config.resource


*** Keywords ***
Open Browser Webpage
[documentation] keyword to open a page in a specific browser
[arguments] ${page} ${browser}
[Documentation] keyword to open a page in a specific browser
[Arguments] ${page} ${browser}

Open Browser ${page} ${browser}
Maximize Browser Window


Default Teardown
Close All Browsers
Close All Browsers
13 changes: 6 additions & 7 deletions resources/pages/data_tables_page.resource
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ Documentation data tables page
Resource base_page.resource


*** Variables ***
${data_tables_title} Data Tables
${email_table_1} //table[@id='table1']//tr/td[3]
Expand All @@ -14,8 +15,7 @@ Go Direct To Data Tables Page
Open Browser Webpage ${HEROKU_TABLES_PAGE} ${BROWSER}
Wait Until Page Contains ${data_tables_title}


verify ${expectedEmails} From Table ${table}
Verify ${expectedEmails} From Table ${table}

Wait Until Page Contains ${table} 2 Available tables: 'Example 1'; 'Example 2'

Expand All @@ -25,16 +25,15 @@ verify ${expectedEmails} From Table ${table}
Lists Should Be Equal ${savedEmails} ${expectedEmails} Incorrect email list; expected emails: @{expectedEmails} ignore_order=True
Capture Page Screenshot


Save Emails From Table
[documentation] Keyword to save emails from a table
[Documentation] Keyword to save emails from a table
[Arguments] ${table}

@{savedEmails}= Create List

IF '${table}' == 'Example 1'
IF $table == 'Example 1'
${elements}= Get WebElements ${email_table_1}
ELSE IF '${table}' == 'Example 2'
ELSE IF $table == 'Example 2'
${elements}= Get WebElements ${email_table_2}
END

Expand All @@ -43,4 +42,4 @@ Save Emails From Table
Append To List ${savedEmails} ${value}
END

[return] ${savedEmails}
RETURN ${savedEmails}
3 changes: 1 addition & 2 deletions resources/pages/the_internet_homepage.resource
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ Open The Internet Homepage
Wait Until Page Contains ${page_intro_text}
Title Should Be ${page_title} Page title should be: ${page_title}


Naviagte To Data Tables Page
Wait Until Element Is Enabled ${data_tables_function}
Click Element ${data_tables_function}
Click Element ${data_tables_function}
2 changes: 1 addition & 1 deletion resources/services/api_base.resource
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,4 @@ Run Post Request
${resp}= POST On Session session ${url} data=${body} expected_status=any headers=${contentType} verify=${False}
Status Should Be 200 ${resp} ${resp.reason}
Log resposta: ${resp.json()}
[Return] ${resp.json()}
RETURN ${resp.json()}
23 changes: 12 additions & 11 deletions resources/services/regres_registration_API.resource
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
*** Settings ***
Documentation registration api
Resource api_base.resource

Resource api_base.resource


*** Variables ***
Expand All @@ -11,18 +10,20 @@ Resource api_base.resource

*** Keywords ***
Email And Password Are Definied As ${email} And ${password}
[documentation] Keyword to generate body with email and password
${body}= set Variable {"email": "${email}", "password": "${password}"}
set test variable ${body} ${body}

[Documentation] Keyword to generate body with email and password
${body}= Set Variable {"email": "${email}", "password": "${password}"}
Set Test Variable ${email} ${email}
Set Test Variable ${body} ${body}

Registration Is Executed
[documentation] Keyword to generate body with email and password
[Documentation] Keyword to generate body with email and password
${resp}= Run Post Request ${API_HOST} ${REGISTRATION_ENDPOINT} ${body}
Set Test Variable ${resp} ${resp}


The Correct Token Is Returned: ${token}
[documentation] Keyword to validate login token
Should Be Equal ${resp}[token] ${token} Token returned isn't the expected: ${token}
The Correct Token Is Returned
[Documentation] Keyword to validate login token
Set Log Level NONE
${token}= Get Environment Variable ${email}
Set Log Level INFO
Should Be Equal ${resp}[token] ${token} Token returned '${resp}[token]' isn't the expected values=${False}
5 changes: 3 additions & 2 deletions tests/API_BDD_with_csv.robot
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ Documentation Robot API BDD with csv test example
Resource resources/services/regres_registration_API.resource

Library DataDriver file=data_files\\users_data.csv dialect=unix
Suite Setup Load Environment Variables


*** Test Cases ***
Expand All @@ -13,7 +14,7 @@ Scenario: Successful Registration With ${email}

*** Keywords ***
Scenario Outline: Successful Registration
[Arguments] ${email} ${password} ${token}
[Arguments] ${email} ${password}
Given email and password are definied as ${email} and ${password}
When registration is executed
Then the correct token is returned: ${token}
Then the correct token is returned
12 changes: 7 additions & 5 deletions tests/API_BDD_with_table.robot
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,20 @@
Documentation Robot API bdd with example table test example
Resource resources/services/regres_registration_API.resource
Suite Setup Load Environment Variables


*** Test Cases ***
Feature: Registration
[Template] Scenario Outline: Successful Registration
eve.holt@reqres.in xpto QpwL5tke4Pnpja7X4
michael.lawson@reqres.in xpto QpwL5tke4Pnpja7X7
lindsay.ferguson@reqres.in xpto QpwL5tke4Pnpja7X8
eve.holt@reqres.in pistol
michael.lawson@reqres.in xpto
lindsay.ferguson@reqres.in xpto


*** Keywords ***
Scenario Outline: Successful Registration
[Arguments] ${email} ${password} ${token}
[Arguments] ${email} ${password}
Given email and password are definied as ${email} and ${password}
When registration is executed
Then the correct token is returned: ${token}
Then the correct token is returned
9 changes: 4 additions & 5 deletions tests/API_keyword_driven.robot
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,21 @@
Documentation Robot API keyword driven test example
Resource resources/services/regres_registration_API.resource
Suite Setup Load Environment Variables


*** Test Cases ***
Successful Registration
email and password are definied as eve.holt@reqres.in and pistol
registration is executed
the correct token is returned: QpwL5tke4Pnpja7X4

the correct token is returned

Successful Registration
email and password are definied as michael.lawson@reqres.in and xpto
Registration Is Executed
the correct token is returned: QpwL5tke4Pnpja7X7

the correct token is returned

Successful Registration
email and password are definied as lindsay.ferguson@reqres.in and xpto
registration is executed
the correct token is returned: QpwL5tke4Pnpja7X8
the correct token is returned
8 changes: 4 additions & 4 deletions tests/data_files/users_data.csv
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
${email},${password},${token}
eve.holt@reqres.in,xpto,QpwL5tke4Pnpja7X4
michael.lawson@reqres.in,xpto,QpwL5tke4Pnpja7X7
lindsay.ferguson@reqres.in,xpto,QpwL5tke4Pnpja7X8
${email},${password}
eve.holt@reqres.in,pistol
michael.lawson@reqres.in,xpto
lindsay.ferguson@reqres.in,xpto
3 changes: 1 addition & 2 deletions tests/web_test_direct_url.robot
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ Verify Emails From Table 'Example 1'
Go Direct To Data Tables Page
Verify ${emails} From Table Example 1


Verify Emails From Table 'Example 2'
Go Direct To Data Tables Page
Verify ${emails} From Table Example 2
Verify ${emails} From Table Example 2
3 changes: 1 addition & 2 deletions tests/web_test_navigate_menus.robot
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,7 @@ Verify Emails From Table 'Example 1'
Naviagte To Data Tables Page
Verify ${emails} From Table Example 1


Verify Emails From Table 'Example 2'
Open The Internet Homepage
Naviagte To Data Tables Page
Verify ${emails} From Table Example 2
Verify ${emails} From Table Example 2

0 comments on commit c236822

Please sign in to comment.