test
import { test, expect } from '@playwright/test';
test("Creating a user story", async({page}) => {
await page.goto("https://demo.playwright.dev/todomvc/#/");
const homePageTitle = await page.locator("//h1[normalize-space(text())='todos']");
const visible = await homePageTitle.isVisible();
expect(visible).toBeTruthy(); // or expect(visible).toBe(true)
const todosInputBox = await page.locator(".new-todo");
await todosInputBox.fill('Task1');
await todosInputBox.press('Enter');
const taskLabel = await page.locator("//label[@data-testid='todo-title']");
const isTaskBisible = await taskLabel.isVisible();
expect(isTaskBisible).toBeTruthy();
const deleteBtn = await page.locator(".destroy");
const isDeleteBtnVisible = await deleteBtn.isVisible();
// expect(isDeleteBtnVisible).toBeTruthy();
if(isDeleteBtnVisible)
{
await deleteBtn.click();
}
const noOfRemTasks = await page.locator("//span[@data-testid='todo-count']");
const no_of_task = await noOfRemTasks.innerText();
console.log("Remaining Tasks left = ",no_of_task);
const actionBtn = await page.locator(".toggle");
await actionBtn.click();
const clearCompletedBtn = await page.locator("//button[normalize-space(text())='Clear completed']");
const isClearBtnVisible = await clearCompletedBtn.isVisible();
expect(isClearBtnVisible).toBe(true);
await clearCompletedBtn.click();
})