{"record":{"id":"9a7854f82d5bbd00","repo":"apify/crawlee","slug":"the-waitforselector-method-is-not-available-s","errorCode":null,"errorMessage":"The `waitForSelector` method is not available - `skipNavigation` was used","messagePattern":"The `waitForSelector` method is not available - `skipNavigation` was used","errorType":"exception","errorClass":"NavigationSkippedError","httpStatus":null,"severity":"error","filePath":"packages/http-crawler/src/internals/http-crawler.ts","lineNumber":572,"sourceCode":"        if (crawlingContext.request.skipNavigation) {\n            return {\n                get contentType(): InternalHttpCrawlingContext['contentType'] {\n                    throw new NavigationSkippedError(\n                        'The `contentType` property is not available - `skipNavigation` was used',\n                    );\n                },\n                get body(): InternalHttpCrawlingContext['body'] {\n                    throw new NavigationSkippedError(\n                        'The `body` property is not available - `skipNavigation` was used',\n                    );\n                },\n                get json(): InternalHttpCrawlingContext['json'] {\n                    throw new NavigationSkippedError(\n                        'The `json` property is not available - `skipNavigation` was used',\n                    );\n                },\n                get waitForSelector(): InternalHttpCrawlingContext['waitForSelector'] {\n                    throw new NavigationSkippedError(\n                        'The `waitForSelector` method is not available - `skipNavigation` was used',\n                    );\n                },\n                get parseWithCheerio(): InternalHttpCrawlingContext['parseWithCheerio'] {\n                    throw new NavigationSkippedError(\n                        'The `parseWithCheerio` method is not available - `skipNavigation` was used',\n                    );\n                },\n            };\n        }\n\n        tryCancel();\n\n        // Before `parseResponse`, which throws for error status codes - a 429 the user opted into treating as an\n        // error is still a rate limit the domain should back off from.\n        if (crawlingContext.response.status === 429) {\n            const retryAfter = crawlingContext.response.headers.get('retry-after');\n            if (this.recordDomainRateLimit(crawlingContext.request.url, retryAfter)) {","sourceCodeStart":554,"sourceCodeEnd":590,"githubUrl":"https://github.com/apify/crawlee/blob/dbe57fb09ca607ad59dcf998f3925ef9ac3bb26c/packages/http-crawler/src/internals/http-crawler.ts#L554-L590","documentation":"NavigationSkippedError thrown by the getter for `waitForSelector` on the crawling context. `waitForSelector` is a browser/DOM API and meaningless without navigation, so it is disabled for `skipNavigation` requests.","triggerScenarios":"Calling `context.waitForSelector(...)` in a handler for a `skipNavigation: true` request (typically in code shared with a browser crawler).","commonSituations":"Porting Playwright/CheerioCrawler-style handlers to HttpCrawler with skipNavigation seeds; copy-pasted handlers including DOM waits that never apply to plain HTTP.","solutions":["Remove `waitForSelector` calls from HTTP handlers or guard them behind `!request.skipNavigation`.","Use plain parsing of `context.body` after a real navigation instead.","Route skipped requests to handlers without DOM helpers."],"exampleFix":"// before\nawait context.waitForSelector('.item');\n// after\nif (!context.request.skipNavigation) { await context.waitForSelector('.item'); }","handlingStrategy":"type-guard","validationCode":"if (!request.skipNavigation && typeof ctx.waitForSelector === 'function') { await ctx.waitForSelector(sel); }","typeGuard":"function supportsDomWait(ctx: CrawlingContext): boolean { return !(ctx.request as any).skipNavigation; }","tryCatchPattern":"try { await ctx.waitForSelector(sel); } catch (err) { if (err instanceof NavigationSkippedError) { /* skip DOM wait for HTTP-only context */ } else throw err; }","preventionTips":["Remove DOM waits from pure HTTP handlers.","Guard browser-only helpers behind crawler type checks.","Share parsing logic, not navigation logic, between crawler types.","Test handlers with skipNavigation requests in CI."],"tags":["skip-navigation","wait-for-selector","http-crawler"],"backgroundTag":"navigation-skipped-property-access","analyzedSha":"dbe57fb09ca607ad59dcf998f3925ef9ac3bb26c","analyzedAt":"2026-08-30T22:22:28.328Z","schemaVersion":2},"datasetVersion":"2026-08-30T23:17:21.991Z"}