Skip to content

Commit

Permalink
Updated Coding Standard
Browse files Browse the repository at this point in the history
  • Loading branch information
NarendraCodeHub committed Jan 12, 2025
1 parent 5f4e320 commit 72e9eb0
Showing 1 changed file with 27 additions and 28 deletions.
55 changes: 27 additions & 28 deletions tests/Forms/Login.spec.js
Original file line number Diff line number Diff line change
@@ -1,57 +1,56 @@
const { test, expect } = require('@playwright/test');

test('Login - Shop',async({page}) => {
await page.goto('https://qa-practice.netlify.app/auth_ecommerce')
// Verify the page title
test('Verify page title: QA Practice | Learn with RV', async ({ page }) => {
await page.goto('https://qa-practice.netlify.app/auth_ecommerce');

// Expect a title "to contain" a substring.
await expect(page).toHaveTitle('QA Practice | Learn with RV')
// Verify that the page title matches the expected value
await expect(page).toHaveTitle('QA Practice | Learn with RV');
});

test('check-form-validation', async ({ page }) => {
// Test form submission without entering any fields
test('Verify form validation for empty fields', async ({ page }) => {
await page.goto('https://qa-practice.netlify.app/auth_ecommerce');

// Check form validation without entering any fields & click on submit
// Attempt to submit the form without filling in the fields
await page.getByRole('button', { name: 'Submit' }).click();

const errorMessage = await page.getByText('Bad credentials! Please try');

// Check if the error message is displayed
const errorMessage = page.getByText('Bad credentials! Please try');
await expect(errorMessage).toBeVisible();

await expect(errorMessage).toHaveText("Bad credentials! Please try again! Make sure that you've registered.");
await expect(errorMessage).toHaveText(
"Bad credentials! Please try again! Make sure that you've registered."
);
});

test('check-form-validation-for-invalid-user-or-password', async ({ page }) => {

// Validate the form with invalid credentials
test('Verify form validation for invalid credentials', async ({ page }) => {
await page.goto('https://qa-practice.netlify.app/auth_ecommerce');

// Fill the form with invalid email and password
await page.locator('#email').fill('[email protected]');

await page.locator('#password').fill('test@123');

await page.getByRole('button', { name: 'Submit' }).click();

const errorMessage = await page.getByText('Bad credentials! Please try');

// Check if the error message is displayed
const errorMessage = page.getByText('Bad credentials! Please try');
await expect(errorMessage).toBeVisible();

await expect(errorMessage).toHaveText("Bad credentials! Please try again! Make sure that you've registered.");

await expect(errorMessage).toHaveText(
"Bad credentials! Please try again! Make sure that you've registered."
);
});

test('check-form-for-valid-user-or-password', async ({ page }) => {

// Validate login functionality with valid credentials
test('Verify login with valid credentials', async ({ page }) => {
await page.goto('https://qa-practice.netlify.app/auth_ecommerce');

// Fill the form with valid email and password
await page.locator('#email').fill('[email protected]');

await page.locator('#password').fill('admin123');

await page.getByRole('button', { name: 'Submit' }).click();

const shoppingCart = await page.locator('text=SHOPPING CART');

// Verify the presence of the shopping cart page
const shoppingCart = page.locator('text=SHOPPING CART');
await expect(shoppingCart).toBeVisible();

await expect(shoppingCart).toHaveText("SHOPPING CART");

await expect(shoppingCart).toHaveText('SHOPPING CART');
});

0 comments on commit 72e9eb0

Please sign in to comment.