From b8a3a60156b49837fc2e5781ff1d02b682a6170c Mon Sep 17 00:00:00 2001 From: Christian Spohr Date: Thu, 23 Nov 2023 10:55:46 +0100 Subject: [PATCH] changed selector with data-testid --- .../invalidCredentials.feature | 14 +++++------ .../login_management/passwordUpdate.feature | 24 +++++++++---------- .../login_management/pageLoginManagement.js | 4 +++- .../invalidCredentialsSteps.spec.js | 6 ++--- 4 files changed, 25 insertions(+), 23 deletions(-) diff --git a/cypress/e2e/login_management/invalidCredentials.feature b/cypress/e2e/login_management/invalidCredentials.feature index be4f2fc2..c8b873af 100644 --- a/cypress/e2e/login_management/invalidCredentials.feature +++ b/cypress/e2e/login_management/invalidCredentials.feature @@ -6,25 +6,25 @@ Feature: Invalid Credentials - Verify login functionality via wrong user data @stable_test Scenario: User uses invalid email and password Given I am on the dBildungscloud login page - Then I see Email field is visible and empty + Then I see email field is visible and empty When I enter invalid email - Then I see Password field is visible and empty + Then I see password field is visible and empty When I enter invalid password - When I click submit button + When I click button Submit Then I see error message @stable_test Scenario: User login with empty fields Given I am on the dBildungscloud login page - When I click submit button + When I click button Submit Then I see form validation message @stable_test Scenario: User uses invalid username and password Given I am on the dBildungscloud login page - Then I see Email field is visible and empty + Then I see email field is visible and empty When I enter invalid username - Then I see Password field is visible and empty + Then I see password field is visible and empty When I enter invalid password - When I click submit button + When I click button Submit Then I see error message \ No newline at end of file diff --git a/cypress/e2e/login_management/passwordUpdate.feature b/cypress/e2e/login_management/passwordUpdate.feature index 6998506b..fa7e6e69 100644 --- a/cypress/e2e/login_management/passwordUpdate.feature +++ b/cypress/e2e/login_management/passwordUpdate.feature @@ -6,11 +6,11 @@ Feature: Password Update - Verify login functionality via password change @stable_test Scenario: User change password, login and change again to old passwords. Given I am on the dBildungscloud login page - Then I see Email field is visible and empty + Then I see email field is visible and empty When I enter email - Then I see Password field is visible and empty + Then I see password field is visible and empty When I enter password - When I click submit button + When I click button Submit When I go to my account settings Then I see current password field is visible and empty Then I see new and repeat password field is visible and empty @@ -23,18 +23,18 @@ Feature: Password Update - Verify login functionality via password change When I logout #Then I see dbildungscloud login page Given I am on the dBildungscloud login page - Then I see Email field is visible and empty + Then I see email field is visible and empty When I enter email - Then I see Password field is visible and empty + Then I see password field is visible and empty When I enter password - When I click submit button + When I click button Submit Then I see error message When I wait for 15 seconds - Then I see Email field is visible and empty + Then I see email field is visible and empty When I enter email - Then I see Password field is visible and empty + Then I see password field is visible and empty When I enter new password - When I click submit button + When I click button Submit When I go to my account settings Then I see current password field is visible and empty Then I see new and repeat password field is visible and empty @@ -47,9 +47,9 @@ Feature: Password Update - Verify login functionality via password change When I logout #Then I see dbildungscloud login page Given I am on the dBildungscloud login page - Then I see Email field is visible and empty + Then I see email field is visible and empty When I enter email - Then I see Password field is visible and empty + Then I see password field is visible and empty When I enter password - When I click submit button + When I click button Submit Then I arrive on the dashboard \ No newline at end of file diff --git a/cypress/support/pages/login_management/pageLoginManagement.js b/cypress/support/pages/login_management/pageLoginManagement.js index d65853ce..19ff6e39 100644 --- a/cypress/support/pages/login_management/pageLoginManagement.js +++ b/cypress/support/pages/login_management/pageLoginManagement.js @@ -11,7 +11,7 @@ class Login_Management { static #emailInputBox = '[data-testid="username-email"]' static #passwordField = '[data-testid = "password-email"]' static #notificationBannerField = '[data-testid="notification"]' - static #loginFormSelector = 'form.login-form' + static #loginFormSelector = '[data-testid = "login-loginform-standard"]' static #inputFieldInvalidPseudoSelector = 'input:invalid' static #userSettingsCurrentPasswordField = '[data-testid="settings_password_current"]' @@ -33,6 +33,8 @@ class Login_Management { errorMessageText: 'Login fehlgeschlagen.' } + // info about checkValidity: https://www.w3schools.com/js/js_validation_api.asp + // info about inputFieldInvalidPseudoSelector: https://glebbahmutov.com/blog/form-validation-in-cypress/ assertEmailFieldIsVisibleAndEmpty () { cy.get(Login_Management.#loginFormSelector).within(() => { cy.get(Login_Management.#emailInputBox) diff --git a/cypress/support/step_definition/login_management/invalidCredentialsSteps.spec.js b/cypress/support/step_definition/login_management/invalidCredentialsSteps.spec.js index 6915316a..104e6870 100644 --- a/cypress/support/step_definition/login_management/invalidCredentialsSteps.spec.js +++ b/cypress/support/step_definition/login_management/invalidCredentialsSteps.spec.js @@ -23,14 +23,14 @@ Then('I see form validation message', () => { loginManagement.assertFormValidationMessageDisplay() }) -Then('I see Email field is visible and empty', () => { +Then('I see email field is visible and empty', () => { loginManagement.assertEmailFieldIsVisibleAndEmpty() }) -When('I click submit button', () => { +When('I click button Submit', () => { loginManagement.clickOnSubmitButton() }) -Then('I see Password field is visible and empty', () => { +Then('I see password field is visible and empty', () => { loginManagement.assertPasswordFieldIsVisibleAndEmpty() })