From bd04b818f55cb5e2a2a83c44c231286b1193a6ad Mon Sep 17 00:00:00 2001 From: najeeb1023 Date: Sun, 23 Jun 2024 19:44:55 +0200 Subject: [PATCH] fix: only to install chrome browser in pipeline and invalid login scenario added. --- .github/workflows/playwright.yml | 2 +- package.json | 2 +- src/test/features/UserLogin.feature | 15 +++++++++++++-- src/test/pages/UserLogin.ts | 17 ++++++++++++++--- src/test/pages/UserShopping.ts | 4 ++-- src/test/steps/userLogin.ts | 4 ++++ 6 files changed, 35 insertions(+), 9 deletions(-) diff --git a/.github/workflows/playwright.yml b/.github/workflows/playwright.yml index 59599ea..8006bbe 100644 --- a/.github/workflows/playwright.yml +++ b/.github/workflows/playwright.yml @@ -16,7 +16,7 @@ jobs: - name: Install dependencies run: npm ci - name: Install Playwright Browsers - run: npx playwright install --with-deps + run: npx playwright install chromium - name: Cucumber-Tests run: npm run cucumber:luma - uses: actions/upload-artifact@v4 diff --git a/package.json b/package.json index abfbccf..9c65eec 100644 --- a/package.json +++ b/package.json @@ -5,7 +5,7 @@ "scripts": { "cucumber:luma": "cucumber-js --config=config/cucumber.js", "cucumber:luma:tags": "cucumber-js --config=config/cucumber.js --tags ", - "cucumber:luma:debug": "cucumber-js --config=config/cucumber.js --tags @MenShopping" + "cucumber:luma:debug": "cucumber-js --config=config/cucumber.js --tags @debug" }, "keywords": [], "author": "", diff --git a/src/test/features/UserLogin.feature b/src/test/features/UserLogin.feature index b24641e..312c25a 100644 --- a/src/test/features/UserLogin.feature +++ b/src/test/features/UserLogin.feature @@ -6,7 +6,8 @@ Feature: Verify that the user is able to login into an already registered accoun Background: User is landed on the webpage. Given The user lands at the webpage. - + + @LoginWithCorrectCredentials Scenario: User is able to login with correct credentials. Given The user clicks on the Sign In button on the header. When The user enters correct "" and "". @@ -14,4 +15,14 @@ Feature: Verify that the user is able to login into an already registered accoun Examples: | EmailAddress | Password | - | facade23@gmail.com | facading123!@ | \ No newline at end of file + | facade23@gmail.com | facading123!@ | + + @LoginWithIncorrectCredentials + Scenario: User is not able to login with incorrect credentials. + Given The user clicks on the Sign In button on the header. + When The user enters correct "" and "". + Then The user is not logged in. + + Examples: + | EmailAddress | Password | + | incorrect@gmail.com | incorrectPassword1231@@ | \ No newline at end of file diff --git a/src/test/pages/UserLogin.ts b/src/test/pages/UserLogin.ts index 0a94d99..74a1242 100644 --- a/src/test/pages/UserLogin.ts +++ b/src/test/pages/UserLogin.ts @@ -1,5 +1,6 @@ import { pageFixture } from "../hooks/pageFixture"; import * as userLoginPage from "../../../src/test/resources/userLoginPage.json"; +import * as registrationpage from "../../../src/test/resources/registrationPage.json"; import { PageElement } from "../resources/interfaces/iPageElement"; import { Page, expect } from "@playwright/test"; @@ -7,6 +8,10 @@ import { Page, expect } from "@playwright/test"; return userLoginPage.webElements.find((element: PageElement) => element.elementName == resourceName) as PageElement; }; + function getResourceRegisterPage(resourceName: string) { + return registrationpage.webElements.find((element: PageElement) => element.elementName == resourceName) as PageElement; + }; + export class LoginUser { constructor (public page: Page){ @@ -18,7 +23,8 @@ export class LoginUser { emailAddress:() => pageFixture.page.locator(getResource('emailAddress').selectorValue), password:() => pageFixture.page.locator(getResource('password').selectorValue), signInUserBtn:() => pageFixture.page.locator(getResource('signInBtn').selectorValue), - welcomeMessage:() => pageFixture.page.locator(getResource('welcomeMessage').selectorValue).first() + welcomeMessage:() => pageFixture.page.locator(getResource('welcomeMessage').selectorValue).first(), + pageMessage:() => pageFixture.page.locator(getResourceRegisterPage('pageMessage').selectorValue) }; public async goToSignIn():Promise{ @@ -37,7 +43,12 @@ export class LoginUser { } else { pageFixture.logger.error('User is not logged in.') } - - + }; + + public async assertUserIsNotLoggedIn():Promise{ + const pageMessage = (await (this.userLoginLocators.pageMessage().textContent())).trim(); + console.log(pageMessage); + expect(this.userLoginLocators.pageMessage()).toContainText('The account sign-in was incorrect or your account is disabled temporarily. Please wait and try again later.') + pageFixture.logger.info('User is logged in.'); }; }; \ No newline at end of file diff --git a/src/test/pages/UserShopping.ts b/src/test/pages/UserShopping.ts index c2c4267..c6bb7a4 100644 --- a/src/test/pages/UserShopping.ts +++ b/src/test/pages/UserShopping.ts @@ -1,6 +1,6 @@ import { pageFixture } from "../hooks/pageFixture"; import * as userShoppingPage from "../resources/userShoppingPage.json"; -import * as registerPage from "../resources/registrationPage.json"; +import * as registrationPage from "../resources/registrationPage.json"; import { PageElement } from "../resources/interfaces/iPageElement"; import { Page, expect } from "@playwright/test"; @@ -9,7 +9,7 @@ import { Page, expect } from "@playwright/test"; } function getResourceRegisterPage(resourceName: string){ - return registerPage.webElements.find((element: PageElement) => element.elementName == resourceName) as PageElement; + return registrationPage.webElements.find((element: PageElement) => element.elementName == resourceName) as PageElement; } export class CategoryAndProductSelectionFacade{ diff --git a/src/test/steps/userLogin.ts b/src/test/steps/userLogin.ts index 6dca46a..1830828 100644 --- a/src/test/steps/userLogin.ts +++ b/src/test/steps/userLogin.ts @@ -15,4 +15,8 @@ When("The user enters correct {string} and {string}.", async function (emailAddr Then("The user is logged in.", async function (){ await userLogin.assertUserIsLoggedIn(); +}); + +Then("The user is not logged in.", async function (){ + await userLogin.assertUserIsNotLoggedIn(); }); \ No newline at end of file