Skip to content

Commit 94865eb

Browse files
committed
Test Case of Add/Remove Elements
1 parent 634ecc4 commit 94865eb

5 files changed

Lines changed: 48 additions & 19 deletions

File tree

constants/configuration.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
// URL'S
2+
export const URLs = {
3+
URL:'https://the-internet.herokuapp.com/',
4+
ADD_REMOVE_ELEMENTS: '/add_remove_elements',
5+
BASIC_AUTH: '/basic_auth'
6+
7+
};

playwright.config.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ export default defineConfig({
2626
/* Shared settings for all the projects below. See https://playwright.dev/docs/api/class-testoptions. */
2727
use: {
2828
/* Base URL to use in actions like `await page.goto('/')`. */
29-
// baseURL: 'http://localhost:3000',
29+
baseURL: 'https://the-internet.herokuapp.com/',
3030

3131
/* Collect trace when retrying the failed test. See https://playwright.dev/docs/trace-viewer */
3232
screenshot: 'only-on-failure',

tests/TC01.spec.ts

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
import { test, expect } from '@playwright/test';
2+
import { URLs } from '../constants/configuration';
3+
4+
test('has title', async ({ page }) => {
5+
await page.goto('/');
6+
await expect(page).toHaveTitle(/The Internet/);
7+
});
8+
9+
test('Test Add/Remove Elements', async ({ page }) => {
10+
await page.goto('/');
11+
await page.locator("a:has-text('Add/Remove Elements')").click();
12+
await expect(page).toHaveURL(URLs.ADD_REMOVE_ELEMENTS);
13+
14+
await expect(page.locator(".example button:has-text('Add Element')")).toBeVisible();
15+
await page.locator(".example button:has-text('Add Element')").waitFor({ state: 'visible' });
16+
await page.locator(".example button:has-text('Add Element')").click();
17+
await page.locator("#elements button:has-text('Delete')").click();
18+
await expect(await page.locator(".added-manually").count()).toBeGreaterThanOrEqual(0);
19+
});
20+
21+
test('Test Basic Auth', async ({ page }) => {
22+
await page.goto('/');
23+
await page.locator("a:has-text('Basic Auth')").click();
24+
await expect(page).toHaveURL(URLs.BASIC_AUTH);
25+
26+
await expect(page.locator(".example button:has-text('Add Element')")).toBeVisible();
27+
await page.locator(".example button:has-text('Add Element')").waitFor({ state: 'visible' });
28+
await page.locator(".example button:has-text('Add Element')").click();
29+
await page.locator("#elements button:has-text('Delete')").click();
30+
await expect(await page.locator(".added-manually").count()).toBeGreaterThanOrEqual(0);
31+
});

tests/example.spec.ts

Lines changed: 0 additions & 18 deletions
This file was deleted.

tsconfig.json

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{
2+
"compilerOptions": {
3+
"baseUrl": "src",
4+
"paths": {
5+
"constants/*": ["constants/*"]
6+
}
7+
}
8+
}
9+

0 commit comments

Comments
 (0)