Skip to content

Request not reaching RequestStages.Response #327

@twisterbr

Description

@twisterbr

Hello!

I can't intercept a request body cause it never gets to the response stage.

The request I want (which has 'api' on it's url) loads together with the page (not when I do any actions).

I tested directly from Chrome inspect > Network and it shows correctly.

What am I doing wrong?

Thanks

async def main():
    options = webdriver.ChromeOptions()
    #options.add_argument('--headless')
    options.add_argument('--disable-blink-features=AutomationControlled')
    options.add_argument('--no-sandbox')
    options.add_argument('--disable-gpu')
    options.add_argument('--disable-dev-shm-usage')
    async with Chrome(options=options) as driver:
        
        url = "https://www.url.com"

        async with NetworkInterceptor(driver, patterns=[RequestPattern.AnyRequest]) as interceptor:
            await driver.get(url, wait_load=False)
            #await driver.sleep(10)
            async for data in interceptor:
                if "api" in data.request.url: print(data.request.headers)
                if data.stage == RequestStages.Response:
                    print("stage")
                    body = await data.body
                    body = json.loads(body)
                    print(body)
                    #print(json.loads(await data.body))
                    #break

asyncio.run(main())

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions