ruby - Cucumber: How to run the After hook only once after all examples in scenarion_outline -


i have scenario_outline tests login screen of website.

scenario_outline:     try login     verify login      examples:     | user  | pass   |     | user1 | pass1  |     | user2 | pass2  | 

i want able start web page @ beginning , close if after examples done.

running before hook easy

before     $start ||= false     if ! start         #start web page         $start = true     end end 

but how run after hook once after scenarios done?

after     #close web page end 

the above example closes web page after first example , causes rest fail. cannot apply here did before hook unfortunately

the reason rest of tests failing because after method not setting global false:

after     #close web page     $start = false end 

i don't believe there afterscenario hook. in situation, if want browser open entire scenario outline, consider using regular scenario , cucumber table. share browser session across each test case.

fyi: there at_exit hook. it's purpose running code after tests.

at_exit #close web page end

https://github.com/cucumber/cucumber/wiki/hooks#global-hooks


Comments

Popular posts from this blog

asp.net mvc - SSO between MVCForum and Umbraco7 -

Python Tkinter keyboard using bind -

ubuntu - Selenium Node Not Connecting to Hub, Not Opening Port -