Closed
Description
Calling the code bellow:
page.waitForFunction("selector => document.querySelectorAll(selector).length === 0", "div[aria-label='Loading timeline']");
results in the error:
Exception in thread "main" com.microsoft.playwright.PlaywrightException: Error {
message='Evaluation failed: EvalError: Refused to evaluate a string as JavaScript because 'unsafe-eval' is not an allowed source of script in the following Content Security Policy directive: "script-src 'self' 'unsafe-inline' https://*.twimg.com https://www.google-analytics.com https://twitter.com https://app.link https://apis.google.com/js/platform.js https://appleid.cdn-apple.com/appleauth/static/jsapi/appleid/1/en_US/appleid.auth.js 'nonce-OTFjOTIzODItM2ViZi00NDQ0LWFhYWYtMTZhZjUwN2FjNjA5'".
at eval (<anonymous>)
at predicate (eval at evaluate (:303:29), <anonymous>:3:35)
at eval (eval at evaluate (:303:29), <anonymous>:18:78)
at onRaf (<anonymous>:1667:37)
Alternatively, i can code the logic like this and it works:
Object pageLoaded = Boolean.FALSE;
while (pageLoaded == Boolean.FALSE) {
pageLoaded = page.evaluate("selector => (document.querySelectorAll(selector).length === 0)",
"div[aria-label='Loading timeline']");
customWait(500);
}
but i still need to know why the first function does not work.
Metadata
Metadata
Assignees
Labels
No labels