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
NoSuchSessionError: Invalid Session id, when Trying to take screenshot ( cucumber with hook file) #506
Comments
Hey @mtahat! It looks like the code samples mix synchronous and asynchronous calls, and screenplay and non-screnplay design. What you'd want in your import { actorCalled, actorInTheSpotlight, Log } from '@serenity-js/core';
import { ResizeBrowserWindow } from '@serenity-js/protractor';
import { After, Before } from 'cucumber';
import { browser } from 'protractor';
Before({ timeout: 2 * 5000 }, () => actorCalled('some actor name').attemptsTo(
ResizeBrowserWindow.toMaximum(),
));
After({ timeout: 2 * 5000 }, () => actorInTheSpotlight().attemptsTo(
ExecuteScript.sync(`window.sessionStorage.clear()`),
ExecuteScript.sync(`window.localStorage.clear()`),
Log.the('any message you want to log'),
)); Please note that calling And in the code sample below: browser.executeScript('window.sessionStorage.clear();').catch(() => { Log.the('sessionStorage Already Cleared!'); }); Calling a
Does this help? Jan |
That's Make perfect sense! Thank you for your quick response. Do I need restratBrowserBetweenTest attribute in the Protractor.congif? it seems like having that attribute True causes issues with the screenshot! |
The changes that @jan-molak suggested for the hook file works for me. now all tests passed no issues with screenshot. I am closing this this issue since it was related to my hook file not serenity js. |
You're most welcome, happy to have helped! If Serenity/JS makes your life easier, make sure to buy us a coffee to keep us going |
I am using Serenity-js with Cucumber, protractor & typescript. I added a hook.js to my framework to close and clean the locale storage session after each feature/scenario. Then I start getting this Invalid session id exception. I also have restartBrowserBetweenTests: true in my protractor.config file.
FYI: I used the template cucumber/serenity template that you have here to build my project. see dependencies below, I am also using Mac book, VS Code IDE.
Hook.ts
Dependencies
The text was updated successfully, but these errors were encountered: