Skip to content

fix: only to install chrome browser in pipeline and invalid login sce… #21

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/playwright.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": "",
Expand Down
15 changes: 13 additions & 2 deletions src/test/features/UserLogin.feature
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,23 @@ 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 "<EmailAddress>" and "<Password>".
Then The user is logged in.

Examples:
| EmailAddress | Password |
| facade23@gmail.com | facading123!@ |
| 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 "<EmailAddress>" and "<Password>".
Then The user is not logged in.

Examples:
| EmailAddress | Password |
| incorrect@gmail.com | incorrectPassword1231@@ |
17 changes: 14 additions & 3 deletions src/test/pages/UserLogin.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,17 @@
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";

function getResource(resourceName: string) {
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){
Expand All @@ -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<void>{
Expand All @@ -37,7 +43,12 @@ export class LoginUser {
} else {
pageFixture.logger.error('User is not logged in.')
}


};

public async assertUserIsNotLoggedIn():Promise<void>{
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.');
};
};
4 changes: 2 additions & 2 deletions src/test/pages/UserShopping.ts
Original file line number Diff line number Diff line change
@@ -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";

Expand All @@ -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{
Expand Down
4 changes: 4 additions & 0 deletions src/test/steps/userLogin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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();
});
Loading