fmondaini fmondaini - 3 years ago 145
Ruby Question

How to implement an AfterStep getting the Tag and passing the scenario as an argument?

I'm searching a way to implement an AfterStep(@tag) passing the scenario as an argument. Unfortunately, this isn't working and I couldn't find a way to do it.

I also looked into the Cucumber Hooks documentation, but that didn't help as well.

The way I'm trying to implement:

AfterStep('@screenshot') do |scenario|
# Add screenshot to baseline folder.
@helper =
@helper.take_screenshot(, 'screenshots/baseline')

When I run the tests, I get this error:

undefined method `name' for #<Cucumber::Core::Test::Result::Passed:0x007f2b818e6d50> (NoMethodError)

The objective here is to take a screenshot from the scenarios with the @screenshot tag.

Answer Source

As @Sam pointed out, using After('@screenshot') do |scenario| did the trick for me.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download