Playwright Crawler fails on undefined page
Hello there! I just build my first actor using the apify cli. I chose to use a typescript playwright crawler. It by default uses the
createPlaywrightRouter()
function to create a router and pass it to the requestHandler
of the PlaywrightCrawler
.
All seems well, and according to typescript, I should be able to access a page
object in the handler. (I'm only using the addDefaultHandler
) However, when I run the actor on the Apify platform it fails with the following exception:
So it seems page
is not defined. I can't seem to find anything in the docs about this. Am I missing something during initialisation?
Any help would be greatly appreciated!3 Replies
sensitive-blue•3y ago
and did you destructure the page in the default handler definition? can you show the code of the defaultHandler?
deep-jadeOP•3y ago
Yes, currently I'm doing the destructuring in the function itself, so I could log the whole context object. But I encountered this error while I was destructuring it in the function arguments as well.
The code itself is just to very generally scroll to the bottom and wait for things to load. Like infinite scroll, but I want it to work on websites without any custom configuration.
sensitive-blue•3y ago
you are referencing page inside the evaluate function this will not work
you can see docs here https://playwright.dev/docs/evaluating
evaluate run in browser enviroment so there is no page object