testng-opening multiple browsers for scenario examples

I have this feature file

Scenario Outline:

  1. Given User is on my website
  2. When User is Admin or Mastering Editor

3.And User is on /page/ page

4.And User click /header/ link

5.Then User should be taken to /target page/

  Examples: Of page, header and target
  | page        | header      | target page           |
  | Homepage    | Master      | Master page           |
  | Homepage    | Translation | Translation page      |

For "Given User is on my website" I wrote the login details, and this is opening new browser for every example in scenario. I want single browser to open and do all examples. can anyone help please

1 answer

  • answered 2021-10-13 10:10 Jayanth Bala

    Follow these steps:

    1. Create one driver class with initialization, closing and some common driver related methods
    2. Create your step definition file with extends this driver class.
    3. Create before class method to initialize the driver
    4. every step will be using the same opened browser

    so every feature file one browser will be initialized.

    public class PersonSteps extends DriverHelper

How many English words
do you know?
Test your English vocabulary size, and measure
how many words do you know
Online Test
Powered by Examplum