Rayrun
← Back to Discord Forum

route function is not working in headless mode please help

palash9088

test.only("verify Moengage integration", async ({ page }) => { let networkRequests = ""; await page.route( "https://sdk-01.moengage.com/v2/report/", async (route, request) => { console.log("1*********************************"); networkRequests = request.postData()!; console.log("2**********************************"); console.log(networkRequests); console.log("3**********************************"); await route.continue(); } ); await page.goto( "https://rohitgupta.wingified.com/moengage.html?id=541364" , { waitUntil: "networkidle" } ); const moengageCookies: any = await page.context().cookies(); expect(JSON.stringify(moengageCookies)).toContain("_vis_opt_exp_20_combi"); console.log(networkRequests); console.log("4**********************************"); });

This thread is trying to answer question "Why is the route function not working in headless mode when trying to verify Moengage integration?"

6 replies
refactoreric

Hi, what are you trying to achieve, and what about it doesn't work/in what way doesn't it work/what are the symptoms?

palash9088

I want to verify that it contains some part of string or not

palash9088

Please check in txt

refactoreric

My guess is that in headless mode, the authentication is unsuccessful. Have you recorded and inspected a trace file? https://playwright.dev/docs/trace-viewer-intro

Another suggestion: page.route is overkill if you only want to inspect a response. In such case you can better use page.waitForResponse: https://playwright.dev/docs/api/class-page#page-wait-for-response

Or, if you have multiple responses that you want to monitor and 'log': https://playwright.dev/docs/api/class-page#page-event-response

palash9088

Checked again with getting all the urls & got to know that https://sdk-01.moengage.com/v2/report/* this is not available in headless mode while getting this in headed mode.

Related Discord Threads

TwitterGitHubLinkedIn
AboutQuestionsDiscord ForumBrowser ExtensionTagsQA Jobs

Rayrun is a community for QA engineers. I am constantly looking for new ways to add value to people learning Playwright and other browser automation frameworks. If you have feedback, email [email protected].