New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
page.waitForFunction() Evaluation failed: EvalError: Refused to evaluate a string as JavaScript #7395
Comments
Is your site publicly available? We would be happy to take a look then. It seems like like they have CSP headers set which prevent you from executing JavaScript functions using evaluate. You can set |
Closing for now since the issue seemed stale. Please reopen with a minimum reproducible. |
Repro for failure @mxschmitt Playwright: 1.14.1 const playwright = require('playwright');
const browser = playwright.chromium.launch()
.then(async (browser) => {
const page = await browser.newPage();
await page.goto('https://github.com/topics/javascript');
const bool = await page.waitForFunction(() => {
const repoCards = document.querySelectorAll('article.border');
return repoCards.length > 30;
})
console.log(bool);
await browser.close();
}) Interestingly, this works (replaced const playwright = require('playwright');
const browser = playwright.chromium.launch()
.then(async (browser) => {
const page = await browser.newPage();
await page.goto('https://github.com/topics/javascript');
const bool = await page.evaluate(() => {
const repoCards = document.querySelectorAll('article.border');
return repoCards.length > 30;
})
console.log(bool);
await browser.close();
}) |
@mxschmitt Resurfacing this issue, as I ran into it again today. The reproduction above still works. |
@mxschmitt I have this issue too. |
I used |
Thank you. I've done the same, and it's working. |
Calling the code bellow:
page.waitForFunction("selector => document.querySelectorAll(selector).length === 0", "div[aria-label='Loading timeline']");
results in the error:
Alternatively, i can code the logic like this and it works:
but i still need to know why the first function does not work.
The text was updated successfully, but these errors were encountered: