thienphuong / playwright-with-typescript

0 stars 0 forks source link

playwright-test and serenity-js should work together #9

Open thienphuong opened 11 months ago

thienphuong commented 11 months ago
import { test, expect } from "@playwright/test";
import { actorCalled, Actor } from "@serenity-js/core";
import { BrowseTheWebWithPlaywright } from "@serenity-js/playwright";
import { Navigate } from "@serenity-js/web";

test("get started link", async ({ page }) => {
  const actor = actorCalled("Jacob").whoCan(
    BrowseTheWebWithPlaywright.usingPage(page)
  );

  await actor.attemptsTo(Navigate.to("google.com"));

  await page.goto("https://playwright.dev/");

  // Click the get started link.
  await page.getByRole("link", { name: "Get started" }).click();

  // Expects page to have a heading with the name of Installation.
  await expect(
    page.getByRole("heading", { name: "Installation" })
  ).toBeVisible();
});
thienphuong commented 11 months ago

Java version

Get driver object from actor

WebDriver driver = BrowseTheWeb.as(actor).getDriver();