How do I define my own StepActions class in a Karate test?
All I need is one working example (apparently nobody has an example of this anywhere; I looked and couldn't find anything and so I am asking here).
For example, how would I implement this helper step action in Java? In this case, how do I get access to the WebDriver driver
instance from within Java context? Then, how do I call the embed?
@Slf4j
public class SeleniumStepActions extends StepActions {
public SeleniumStepActions(FeatureContext featureContext, CallContext callContext, Scenario scenario, LogAppender appender) {
super(featureContext, callContext, scenario, appender);
}
@When("^screenshot$")
public void takeAScreenShot()
{
// goals is to simulate this in a karate js test
// * def bytes = driver.screenshot()
// * karate.embed(bytes, 'image/png')
log.info("Testing my own custom action.");
}
}
It is possible the above won't work. I am just looking to be pointed in the right direction by someone who knows. I wish there was such an example in the karate demo.