Thanks Laskhya. Im aware of the use of the hooks. But rathet confused by 
the syntax.. Here are the blocks in my projects hooks.rb

Sometimes "scenario" is passed, Sometimes "scenario" and "block" are 
passed. Its quite confusing how exactly its doing?

Before do
 @browser = browser
end
Before do|scenario|
 ENV['HTTP_PROXY'] = ENV['http_proxy'] = nil
 DataMagic.load('order_details.yml')
 DataMagic.load_for_scenario(scenario)
end
After do |scenario|
 @browser.execute_script("javascript:localStorage.clear();")
 @browser.cookies.clear
 if (scenario.passed?)
 puts 'Scenario Passed !'
 else
 puts 'Scenario Failed !'
 end
end
AfterStep('@screen') do
 filename = DateTime.now.strftime("%d%b%Y%H%M%S")
 @browser.screenshot.save (
"C:/Users/lohit.kotian/Documents/Automation/screenshots-cucumber/#{filename}.png"
)
 #@browser.screenshot.save 
("C:/Jenkins/workspace/screenshots-cucumber/#{filename}.png")
end
Around('@multipletimes') do |scenario, block|
 $counter = 0
 $total_times_to_run = 6
 while $counter < $total_times_to_run do
 block.call
 puts("Total times scripts were repeated = #$counter" )
 $counter +=1
 end
end
After do |scenario|
 take_screenshot(@browser, scenario)
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.

watir-general@googlegroups.com
http://groups.google.com/group/watir-general
watir-general+unsubscr...@googlegroups.com
--- 
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 watir-general+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to