Add basic E2E Login tests

This commit is contained in:
Bubka 2022-08-04 21:32:24 +02:00
parent 4e83c6c2f6
commit d1708b9c9b
7 changed files with 168 additions and 0 deletions

View File

@ -0,0 +1,12 @@
*** Settings ***
Documentation A page object to use in Accounts tests.
...
Library SeleniumLibrary
Resource ../common.resource
*** Variables ***
&{ACCOUNTS_PAGE} url=http://${SERVER}/accounts title=Accounts
*** Keywords ***
Accounts Page Should Be Open
Page Should Be Open ${ACCOUNTS_PAGE}

View File

@ -0,0 +1,50 @@
*** Settings ***
Documentation A page object to use in Login tests.
...
Library SeleniumLibrary
Resource ../common.resource
*** Variables ***
&{LOGIN_PAGE} url=http://${SERVER}/login title=Login
${EMAIL FIELD} emlEmail
${EMAIL FIELD ERROR} valErrorEmail
${PASSWORD FIELD} pwdPassword
${PASSWORD FIELD ERROR} valErrorPassword
${LEGACY FORM} frmLegacyLogin
${SIGN IN BUTTON} btnSignIn
${CONTINUE WITH WEBAUTHN BUTTON} btnContinue
${SIGN IN WITH WEBAUTHN LINK} lnkSignWithWebauthn
${SIGN IN WITH LOGIN PASSWORD LINK} lnkSignWithLegacy
${RECOVER YOUR ACCOUNT LINK} lnkRecoverAccount
${RESET PASSWORD LINK} lnkResetPwd
*** Keywords ***
Open Browser To Legacy Login Page
Open Browser To Page ${LOGIN_PAGE}
Show Legacy Form
Go To Legacy Login Page
Go To Page ${LOGIN_PAGE}
Show Legacy Form
Submit Credentials To Legacy Form Login
[Arguments] ${username} ${password}
Input Text ${EMAIL FIELD} ${username}
Input Text ${PASSWORD FIELD} ${password}
Click Button ${SIGN IN BUTTON}
Email Field Should Show An Error
Field Should Show An Error ${EMAIL FIELD ERROR}
Password Field Should Show An Error
Field Should Show An Error ${PASSWORD FIELD ERROR}
Show Legacy Form
${is_not_visible}= Run Keyword And Return Status Element Should Be Visible ${SIGN IN WITH LOGIN PASSWORD LINK}
Run Keyword If ${is_not_visible} Click Link ${SIGN IN WITH LOGIN PASSWORD LINK}
Element Should Be Visible ${LEGACY FORM}
Show Webauthn Form
${is_not_visible}= Run Keyword And Return Status Element Should Be Visible ${SIGN IN WITH WEBAUTHN LINK}
Run Keyword If ${is_not_visible} Click Link ${SIGN IN WITH WEBAUTHN LINK}
Element Should Not Be Visible ${LEGACY FORM}

View File

@ -0,0 +1,9 @@
*** Settings ***
Documentation A resource file for authentication tests.
...
Library SeleniumLibrary
Resource ../../common.resource
*** Variables ***
${VALID USER} testing@2fauth.app
${VALID PASSWORD} password

View File

@ -0,0 +1,20 @@
*** Settings ***
Documentation A test suite containing tests related to the login page links.
Suite Setup Open Browser To Legacy Login Page
Suite Teardown Close Browser
Resource ../../Pages/login_page.robot
*** Test Cases ***
Reset Link
Element Should Be Visible ${RESET PASSWORD LINK}
Webauthn login Link
Element Should Be Visible ${SIGN IN WITH WEBAUTHN LINK}
Legacy login Link
Show Webauthn Form
Element Should Be Visible ${SIGN IN WITH LOGIN PASSWORD LINK}
Recover Account Link
Show Webauthn Form
Element Should Be Visible ${RECOVER YOUR ACCOUNT LINK}

View File

@ -0,0 +1,31 @@
*** Settings ***
Documentation A test suite containing tests related to invalid login.
Suite Setup Open Browser To Legacy Login Page
Suite Teardown Close Browser
Test Setup Go To Legacy Login Page
Resource ../../Pages/login_page.robot
Resource authentication.resource
*** Test Cases ***
Invalid Email
[Template] Login With Invalid Email Should Fail
${EMPTY} ${VALID PASSWORD}
invalid ${VALID PASSWORD}
email@donot.exist ${VALID PASSWORD}
Missing Password
Submit Credentials To Legacy Form Login ${VALID USER} ${EMPTY}
Location Should Be ${LOGIN_PAGE.url}
Password Field Should Show An Error
Invalid Password
Submit Credentials To Legacy Form Login ${VALID USER} invalid
Location Should Be ${LOGIN_PAGE.url}
An Error should be notified
*** Keywords ***
Login With Invalid Email Should Fail
[Arguments] ${username} ${password}
Submit Credentials To Legacy Form Login ${username} ${password}
Location Should Be ${LOGIN_PAGE.url}
Email Field Should Show An Error

View File

@ -0,0 +1,12 @@
*** Settings ***
Documentation A test suite containing tests related to valid login.
Suite Setup Open Browser To Legacy Login Page
Suite Teardown Close Browser
Resource ../../Pages/login_page.robot
Resource ../../Pages/accounts_page.robot
Resource authentication.resource
*** Test Cases ***
Valid Login
Submit Credentials To Legacy Form Login ${VALID USER} ${VALID PASSWORD}
Accounts Page Should Be Open

View File

@ -0,0 +1,34 @@
*** Settings ***
Documentation A resource file with reusable keywords and variables.
Library SeleniumLibrary
*** Variables ***
${SERVER} localhost
${BROWSER} chrome
${DELAY} 0.1
*** Keywords ***
Open Browser To Page
[Arguments] ${page}
Set Selenium Speed ${DELAY}
Open Browser ${page.url} ${BROWSER}
Page Should Be Open ${page}
An Error should be notified
Element Should Be Visible id:vueNotification >> class:is-danger
Go To Page
[Arguments] ${page}
Go To ${page.url}
Page Should Be Open ${page}
Page Should Be Open
[Arguments] ${page}
Location Should Be ${page.url}
Title Should Be ${page.title}
Field Should Show An Error
[Arguments] ${field error}
Element Should Be Visible ${field error}
Should Not Be Empty ${field error}