Multiple sessions screenshot on failing

Hello,
is there a way to save a screenshot of each session() created on the scenario after failing?

Feature("Testing");

Scenario("Screenshot multiple sessions", (I) => {
	session("one", () => {
		I.amOnPage('http://google.com');
		I.dontSeeInCurrentUrl('http://google.com');
	});
        session("two", () => {
		I.amOnPage('http://google.com');
		I.dontSeeInCurrentUrl('http://google.com');
	});
        session("one", () => {
		I.dontSeeInCurrentUrl('http://google.com');
	});
});

I think we already had it. But only with Puppeteer and Playwright.

Oh, I’m working with selenium webdriver…

I can create a custom helper and initialize a new webdriver on it and finally add the screenshot to the _failed(), but I don’t think is the best approach, right?
Sessions are a way easier to work with.

Is it possible to have the same result with on webdriver? Or to have a work around?

I guess codeceptjs would offer this in their new release.

1 Like

Hello again, after the new release i couldn’t figure out how to have both screenshots after failing.

 Feature("Testing sessions");
Scenario("Sessions 1 @level1", async function ({ I }) {
  await I.amOnPage("/");
  session("john", async () => {
    await I.amOnPage("/");
    await I.see("You");
  });
});

Current codeceptjs version: 3.6.4
Output folder:
2024-07-03_11-16

Please let me know if I’m doing something wrong.

Maybe I understood incorrectly but seems like it works like it should be? the failure happens on your session, so only session screenshot is captured not the main session, as the failure is not happening there. :thinking:

soo we shouldn’t get the screenshot of all the browsers after fail? right after the PR i was getting all the screenshot but just a short period of time.

btw, if one session (ex: “john”) fails i don’t get the screenshot attached to the allure report.
I get the attached screenshot only if the test fails on the main session.
Report:


Code:

Feature('Session');

Scenario('should save screenshot for sessions @session', async ({ I }) => {
  await I.amOnPage('/');
  await I.amOnPage('/browsevideos');
  await session('john', async () => {
    await I.amOnPage('/browsevideos');
    await I.see('Fake text');// Fails here
  });
});