From 2fe5e5c33d98464a85142747b85d64935b9c52a3 Mon Sep 17 00:00:00 2001 From: David Hunt Date: Mon, 14 Oct 2024 14:47:59 +1300 Subject: [PATCH] a few more items --- packages/playwright/src/outcomes.steps.ts | 35 ++++++++++++++++++-- packages/playwright/tests/playwright.feature | 2 +- 2 files changed, 34 insertions(+), 3 deletions(-) diff --git a/packages/playwright/src/outcomes.steps.ts b/packages/playwright/src/outcomes.steps.ts index 1b021f6..68cbc50 100644 --- a/packages/playwright/src/outcomes.steps.ts +++ b/packages/playwright/src/outcomes.steps.ts @@ -45,7 +45,38 @@ Then('I should not see a(n)/the {string} {word}', async function (world:Playwrig await expect(locator).not.toBeVisible() }) - +Then('a/an/the {string} should be disabled', async function (world:PlaywrightWorld, identifier) { + let locator = await getLocator(world.page, identifier, 'element') + await expect(locator).toBeDisabled() +}) +Then('a/an/the {string} should be enabled', async function (world:PlaywrightWorld, identifier) { + let locator = await getLocator(world.page, identifier, 'element') + await expect(locator).toBeEnabled() +}) +Then('a/an/the {string} should be checked', async function (world:PlaywrightWorld, identifier) { + let locator = await getLocator(world.page, identifier, 'element') + await expect(locator).toBeChecked() +}) +Then('a/an/the {string} should be unchecked', async function (world:PlaywrightWorld, identifier) { + let locator = await getLocator(world.page, identifier, 'element') + await expect(locator).not.toBeChecked() +}) +Then('a/an/the {string} should be focused/active', async function (world:PlaywrightWorld, identifier) { + let locator = await getLocator(world.page, identifier, 'element') + await expect(locator).toBeFocused() +}) +Then('a/an/the {string} should be unfocused/blurred', async function (world:PlaywrightWorld, identifier) { + let locator = await getLocator(world.page, identifier, 'element') + await expect(locator).not.toBeFocused() +}) +Then('a/an/the {string} should be visible', async function (world:PlaywrightWorld, identifier) { + let locator = await getLocator(world.page, identifier, 'element') + await expect(locator).toBeVisible() +}) +Then('a/an/the {string} should be hidden/invisible', async function (world:PlaywrightWorld, identifier) { + let locator = await getLocator(world.page, identifier, 'element') + await expect(locator).not.toBeVisible() +}) Then('a/an/the {string} {word} should be disabled', async function (world:PlaywrightWorld, identifier, role) { let locator = await getLocator(world.page, identifier, role) await expect(locator).toBeDisabled() @@ -58,7 +89,7 @@ Then('a/an/the {string} {word} should be checked', async function (world:Playwri let locator = await getLocator(world.page, identifier, role) await expect(locator).toBeChecked() }) -Then('a/an/the {string} {word} should be unchecked', async function (world:PlaywrightWorld, identifier, role) { +Then('a/an/the {string} {word} should be unchecked', async function (world:PlaywrightWorld, identifier, role) { let locator = await getLocator(world.page, identifier, role) await expect(locator).not.toBeChecked() }) diff --git a/packages/playwright/tests/playwright.feature b/packages/playwright/tests/playwright.feature index 90d681f..ac0af41 100644 --- a/packages/playwright/tests/playwright.feature +++ b/packages/playwright/tests/playwright.feature @@ -14,7 +14,7 @@ Feature: Basic tests of Playwright browser and steps When I click on the "Form" link Then the url should contain "#form" When I click on "Message:" - Then the active element should be a "textarea" + Then the "textarea" should be focused @concurrent Rule: Playwright should support testing with multiple browsers