Using Within Playwright
ilrein opened this issue · comments
Ilia commented
I see the docs has an example of how to use gremlins within cypress. Is there a way to do the same, but using Playwright instead?
Nikos Pantelaios commented
I have the same question, does this work with playwright? My code is like this:
await page.evaluate(() => { gremlins.createHorde().unleash()}).catch(e => void 0);
And I get window is not defined error. Any help?
Jean-François Greffier commented
Here is something that worked for me
import { test } from "@playwright/test";
test("run gremlins.js", async ({ page }) => {
await page.addInitScript({
path: "./node_modules/gremlins.js/dist/gremlins.min.js",
});
await page.goto("https://playwright.dev");
await page.evaluate(() => gremlins.createHorde().unleash());
});
Jean-François Greffier commented
Hi there! I've made a pull request to add an example for Playwright