Skip to content

How to run many different Scenario() without closing the browser? #37

Closed

Description

@arsa666

How to run many different Scenario() without closing the browser? This is my code:

Before((I) => {
    I.amOnPage('/');
    I.fillField('email', 'someEmail@gmail.com');
    I.fillField('password', '123456');
    I.click('Sign in');
});

Scenario('Check to see if it has landing page and welcome msg', (I) => {
    I.see('Welcome to Casefriend Version 1.0');
    I.amOnPage('http://cflocal/#landing');


});

Scenario('Logining into Casefriend', (I) => {
    I.click('Users');
    I.click('New User');
});

This code passes correctly but it opens firefox, test Scenario 1 then closes firefox, opens again, and tests second Scenario. I want it to do everything on one single firefox instance. How can I do?

Activity

  1. DavertMik commented on Dec 20, 2015

    @DavertMik
    Contributor

    I think this is a good feature that will be available soon in upcoming releases )
    Thanks for the suggestion

  2. fabioel commented on Jan 5, 2016

    @fabioel
    Contributor

    @DavertMik It would be really awesome if the state is reset to the initiale state of the site after each test, in order to enable a clean testing environment. (This is something CasperJS has issues with 😉)

  3. smozely commented on May 31, 2016

    @smozely

    @DavertMik
    This is kinda killer for working with SauceLabs (starting browsers there is slooow)

    I've been looking at how to implement this today ... Basic plan of attack is just a custom WebDriverIO Helper that only starts the browser if it hasn't already been created... This could then be easily be expanded to work off a config option, and I'd probably add that after a test fails, it might be worth restarting the browser.

    ... only problem is there is no beforeAll/afterAll currently implemented (as per #103) so there is no place to hook into really shut down the browser ... any thoughts on doing this?

  4. Nighthawk14 commented on Jul 22, 2016

    @Nighthawk14
    Contributor

    @smozely I created a PR with this feature for Protractor/Selenium, I can try to look into it for webdriver.io or If you want to have a look feel free. #167

  5. HughZurname commented on Jan 9, 2017

    @HughZurname
    Contributor

    @fabioel Have you tried using Nightmare? There's a setting that effectively does what you're referring to.
    Below is an extract from my helpers config:

    Nightmare: {
          url: 'http://localhost:3000',
          webPreferences: {
            partition: 'nopersist'
          }
       }
    
  6. APshenkin commented on Jun 1, 2017

    @APshenkin
    Contributor

    Closing this issue, now there is restart option that can be used for disabling browser restart

  7. FathimaAfshan commented on Feb 3, 2025

    @FathimaAfshan

    helpers: {
    Playwright: {
    browser: 'chromium',
    url: '***',
    show: true,
    keepBrowserState: true, // This ensures cookies and session are maintained across scenarios
    restart: false, // Prevents browser from restarting after each scenario
    keepCookies: true,
    }
    }

    I have given restart as 'false' but still the browser is getting relaunched after every scenario

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions