You are welcome! The order of execution will always be:
iteration 1 -> Before Hook Scenario Steps After Hook iteration 2 -> Before Hook Scenario Steps After Hook iteration 3 -> Before Hook Scenario Steps After Hook This is also a good practice, so that your Scenarios always start from a clean state - new browser instance, new login session, etc. The difference between the two Before hooks you shared is that you are getting access the *scenario* object in the second one. This object allows you to get info such as Scenario title, description, tags, pass/fail status in After hook, and so on. This doc will help you figure out all the methods you can use on that object - https://www.rubydoc.info/github/cucumber/cucumber-ruby/ On Thursday, January 31, 2019 at 9:25:11 PM UTC-8, NaviHan wrote: > > Thanks Lakshya for the detailed explanation. > > So if I want to execute a scenario 3 times, here is the order of execution > > iteration 1 -> Before Hook Scenario Steps After Hook > iteration 2 -> Before Hook Scenario Steps After Hook > iteration 3 -> Before Hook Scenario Steps After Hook > > Or is it > > Before Hook > iteration 1 -> Scenario Steps > iteration 2 -> Scenario Steps > iteration 3 -> Scenario Steps > After Hook > > Also what is the difference between > > Before do > @browser = browser > end > > and > > > Before do |scenario| > @browser = browser > end > > > > On Tuesday, 29 January 2019 16:47:10 UTC+11, NaviHan wrote: >> >> Hi all >> >> Im just looking for some good documentation which explains the usage of >> blocks in hooks.rb >> >> For example "Before", "After" , "AfterStep" etc... >> >> Thanks in advance >> > -- -- Before posting, please read https://github.com/watir/watir_meta/wiki/Guidelines-for-Posting-to-Watir-General-Google-Group. In short: search before you ask, be nice. [email protected] http://groups.google.com/group/watir-general [email protected] --- You received this message because you are subscribed to the Google Groups "Watir General" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. For more options, visit https://groups.google.com/d/optout.
