2

Hi We have configured driver in the feature file. I am able to set the zaleniumTestStatus cookie from the feature file using And cookie({ name: 'zaleniumTestPassed', value: 'true' }) . I want to do same from the Java Hook. How do I get driver object in execution hook. I tried as below but not luck..

@Override public void afterScenario(ScenarioResult scenarioResult, ScenarioContext scenarioContext) {

    Cookie cookie = new Cookie("zaleniumTestPassed", "false");
    scenarioContext.cookie("zaleniumTestPassed", "true");
   
}

I want to do something like this.. driver.get().manage().addCookie(cookie);

1 Answers1

0

Why don't you do it in 2 steps. First set a variable. And in your test, if that variable is set, set a cookie.

Because unfortunately a driver is not initialized until the first URL navigation is made. If you explain what you are trying to do - this may be a potential feature request.

Peter Thomas
  • 54,465
  • 21
  • 84
  • 248
  • We are trying to update the test status in the Zalenium dashboard. I believe that I can achieve that by adding a cookie to the driver. – Srikanth Srinivas Sep 22 '20 at 20:25
  • @SrikanthSrinivas contribute code or follow this process: https://github.com/intuit/karate/wiki/How-to-Submit-an-Issue – Peter Thomas Sep 23 '20 at 03:49