Using Within Playwright
ilrein opened this issue · 3 comments
ilrein 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?
npantelaios 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?
jfgreffier 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());
});
jfgreffier commented
Hi there! I've made a pull request to add an example for Playwright