Untitled

mail@pastecode.io avatar
unknown
plain_text
a year ago
1.4 kB
1
Indexable
import { page } from "../setup";
import { expect } from "@playwright/test";
import { When, Then, After } from "@cucumber/cucumber";

let names = "";

When("I click choose {string}", async function (pageName: string) {
  await page.locator("//div[@class='ml-2 mr-2 mobile-hidden']").waitFor({ state: "visible" });
  await page.locator("//div[@class='ml-2 mr-2 mobile-hidden']").click();
  await page.getByRole("menuitem", { name: pageName }).click();
});

When("I update my profile with {string} and {string}", async function (firstName: string, lastName: string) {
  names = firstName + " " + lastName;
  await page.locator('input[name="firstName"]').textContent();
  await page.locator('input[name="surname"]').textContent();
  await page.locator('input[name="firstName"]').fill(firstName);
  await page.locator('input[name="surname"]').fill(lastName);
});

When("I click {string} button", async function (buttonText: string) {
  this.targetButton = buttonText;
  await page.getByRole("button", { name: `${buttonText}` }).click();
});

Then("I should see the information updated successfully", async function () {
  await page.getByRole("button", { name: `${names}` }).waitFor();
  const displayedtext = await page
    .getByRole("button", { name: `${names}` })
    .first()
    .textContent();
  expect(displayedtext).toMatch(`${names}`);
});