Skip to content

having playwright trace when using multiple sessions sessions #4981

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

Open
julien-ft-64 opened this issue Apr 29, 2025 · 4 comments · May be fixed by #4992
Open

having playwright trace when using multiple sessions sessions #4981

julien-ft-64 opened this issue Apr 29, 2025 · 4 comments · May be fixed by #4992

Comments

@julien-ft-64
Copy link

Hello,

Here is my use case : i'm using 2 sessions using playwright as driver with trace enabled for failed tests, with bdd enabled and allure reporting.

When a test fails, there allure report manage the multiples sessions on steps like console logs but trace folder only contains main/default browser and not the created sessions browser instance.

Would it be possible to enable traces when a session is created, adding session name to zip file would also be nice.

Thank you.

@kobenguyent
Copy link
Collaborator

@julien-ft-64
Copy link
Author

Hello,

I'm on 3.6.3, the playwright helper does have the same code but it's not saving traces.

i added some console output in the helper in node modules, it does iterate on sessions, and context is not null but no trace file are saved for other sessions. Only main one

@julien-ft-64
Copy link
Author

julien-ft-64 commented May 13, 2025

I think i tackle the issue root cause , i changed the .context in session usage to context() (for session it's a function, not a property)

and another issue : the naming convention, putting sessionname before testname as it's length is limited to 245 char is save function. When having gherkin with tags it make the same shortenned name, and the default session being written last, it overwrite the "previous" one(s).

test.artifacts[`trace_${sessionName}`] = await saveTraceForContext(
          this.sessionPages[sessionName].context(),
          `${sessionName}_${test.title}.failed`
        )

i would have made a PR but i'm also now getting an error due to playwrigth trace management that i don't know how to prevent:

Error: tracing.stop: Must start tracing before stopping

@julien-ft-64
Copy link
Author

Found the reason of the error (main session was saved before loop and inside sessions loop).

Made a PR about this use case : #4992

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

Successfully merging a pull request may close this issue.

2 participants