Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] Tracing does not work with playwright.request.newcontext() #137

Open
jnjgomez10 opened this issue Oct 28, 2022 · 3 comments
Open

[BUG] Tracing does not work with playwright.request.newcontext() #137

jnjgomez10 opened this issue Oct 28, 2022 · 3 comments

Comments

@jnjgomez10
Copy link

Context:
I am using playwright to test REST API endpoints.
I do not see trace.zip after I run pytest --tracing=on.

Code Snippet

Simple test script

import os
from typing import Generator

import pytest
from playwright.sync_api import Playwright, APIRequestContext


@pytest.fixture(scope="session")
def api_request_context(
    playwright: Playwright,
) -> Generator[APIRequestContext, None, None]:
    request_context = playwright.request.new_context(
        base_url="https://api.publicapis.org",
        ignore_https_errors=True
    )
    yield request_context
    request_context.dispose()

def test_should_create_bug_report(api_request_context: APIRequestContext) -> None:
    response = api_request_context.get("/entries")
    assert response.ok

Describe the bug

pytest --tracing=on test_mytest.py does not produce trace.zip

@mxschmitt mxschmitt transferred this issue from microsoft/playwright-python Oct 28, 2022
@QuLogic
Copy link

QuLogic commented Nov 4, 2022

AFAICT, it also doesn't work with Browser.new_context (e.g., using the browser fixture to create a context with a different scale factor browser.new_context(device_scale_factor=2)); not sure if that ends up using the same APIRequestContext in the end.

Edit: Ah, maybe what I'm seeing is #99.

@guandalf
Copy link

And this is particularly problematic as the only way to test chrome extensions is by creating a new context as per https://playwright.dev/python/docs/chrome-extensions

Please help :)

@guandalf
Copy link

In fact I just reimplemented my fixture copying it from

and creating the context the way I need it and everything worked as expected. Might not help in all cases but to me it kinda solved....

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants