How to start a fresh browser session for each feature files

35 views Asked by At

Is there a way to restart a fresh browser session after executing each feature files. As of now either fresh browser session is getting started after each scenario or it waiting to complete all scenarioes in each of the feature files.

I have used "serenity.restart.browser.for.each=feature" property to handle my requirement but it does not work.

My expectation is that the browser closed after executing a feature file and start a fresh session for the next feature file.

Feature File 1:

Feature: Login Functionality

  As a user I want to login into the LMS



  Background:

    Given that the user is on login page

    And username and password fields are there



  Scenario Outline: Invalid Login Scenario

    When I enter <username>

    And enter <password>

    And click on login button

    Then Validate <Alert> message



    Examples:

      | username            | password   | Alert                           |

      | [email protected]    | Melimu@123 | Invalid login, please try again |

      | [email protected] | Pass@123   | Invalid login, please try again |



  Scenario Outline: Successful Login Scenario

    When I enter <username>

    And enter <password>

    And click on login button

    Then user should be logged in successfully



    Examples:

      | username            | password   |

      | [email protected] | Melimu@123 |



Feature File 2:

Feature: Forgot Password Functionality

  Users have the option to recover their password if they forget it



  Background:

    Given that the user is on login page

    And forgot password button is there

    And user clicks on forgot password button



  Scenario Outline: reset password by username

    Given that the username field is there

    When user enters <username>

    And click on search button

    Then user should be redirected to a new page

    And the <message> will be validated



    Examples:

      | username            | message                                                                                         |

      | [email protected] | If you supplied a correct username or email address then an email should have been sent to you. |

      | [email protected]    | If you supplied a correct username or email address then an email should have been sent to you. |



  Scenario Outline: reset password by email

    Given that the email field is there

    When user enters <email>

    And click on search button

    Then user should be redirected to a new page

    And the <message> will be validated



    Examples:

      | email                               | message                                                                                         |

      | [email protected] | If you supplied a correct username or email address then an email should have been sent to you. |



  Scenario Outline: User resets their password with a valid reset link

    Given the user has received a password reset email

    When the user clicks on the password reset link in the email

    Then the user should be directed to the Reset Password page

    When the user enters and confirms a <new password>

    And submits the new password

    Then the user should see a <success message>



    Examples:

      | email                                    | new password | success message             |

      | [email protected] | Melimu@123   | Your password has been set. |





Feature File 3:

Feature: Create users manually

  Admin will create a user account into the LMS



  Scenario Outline: User redirects to create user page

    Given log in as admin with <username> and <password>

    And user is on the dashboard

    And company management block is there

    When user clicks on users tab

    And click on create user

    Then user is on create user page



    Examples:

      | username               | password   |

      | [email protected] | Melimu@123 |



  Scenario Outline: Checking mandatory fields on create user page

    When user clicks on submit button

    Then there should be an <alert>

    And verify the mandatory fields



    Examples:

      | alert                                           |

      | There are required fields in this form marked . |



  Scenario Outline: Manually creating users

    When user enter <first name>, <last name>, <email address> and <new password>

    And user enables Use email address as user name radio button

    And disable force password change option

    And select no in send temporary passwords by email drop down

    And user clicks on submit and create another user button

    Then verify the successfull user creation <success alert>



    Examples:

      | role    | first name | last name | email address       | new password | success alert             |

      | Teacher | Test       | Teacher   | [email protected] | Melimu@123   | User created successfully |

      | Learner | Test       | Learner 1 | [email protected] | Melimu@123   | User created successfully |

      | Learner | Test       | Learner 2 | [email protected] | Melimu@123   | User created successfully |


0

There are 0 answers