Forum Discussion

Camo's avatar
Camo
Occasional Contributor
4 years ago

Is it possible to get scenario inside the step in Cucumber?

I need to make screenshot inside the step on specific place. It means not on @BeforeStep nor on @AfterStep. I need to call

// public void someStep(Scenario scenario)  // This does not work

public void someStep()
{
    page.openUrl();
    scenario.attach(screenshot(), "image/png", fileName1);
    page.doSomething();
    scenario.attach(screenshot(), "image/png", fileName2);
    page.doSomethingElse();
}

But I am not able to get current scenario related to the step execution. Is it possible or not? I tried to call it like someStep(Scenarion scenario) but it throws an error.

 

Thanks for any help.