Skip to content

having playwright trace when using multiple sessions sessions #4981

Open
@julien-ft-64

Description

@julien-ft-64

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.

Activity

julien-ft-64

julien-ft-64 commented on May 13, 2025

@julien-ft-64
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

julien-ft-64 commented on May 13, 2025

@julien-ft-64
Author

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

julien-ft-64 commented on May 14, 2025

@julien-ft-64
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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Participants

      @kobenguyent@julien-ft-64

      Issue actions

        having playwright trace when using multiple sessions sessions · Issue #4981 · codeceptjs/CodeceptJS