Best approach to initialize and quit driver in Page Object Design Pattern with Selenium PageFactory in Cucumber.

Question is w.r.t the blog, Page Object Design Pattern with Selenium PageFactory in Cucumber, url: https://www.toolsqa.com/selenium-cucumber-framework/page-object-design-pattern-with-selenium-pagefactory-in-cucumber/

The driver is actually initialized inside step definitions, @Given  and driver.quit within one of the  step, @When(“^place the order$”). This actually results in adding at a least driver.quit at many places if I am going initialize and quit driver for each of the tests.  Instead of this approach can we use annotations provided Cucumber/Junit @Before and @After annotations to take the code out of @Given and driver.quit at many other places. To put it in simple words, I do not want to use initialize and quit driver within step definitions. Whats the best approach? How should I design my classes? Please help.

Add Comment
  • 0 Answer(s)
  • Your Answer

    By posting your answer, you agree to the privacy policy and terms of service.