hemagb
hemagb

Reputation: 11

Karate Framework for web automation

I have a scenario when automating the UI using karate. It all works well, however when a step fails the execution ends(karate closes the browser) and this leaves the system under test in a weird state. Is there a way to have a graceful exit, for instance if the step failed and the control could pass on to a clean up function or continue executing the next steps by having the browser still active, so that user can gracefully exit by clicking on the logout button ?

Upvotes: 1

Views: 311

Answers (1)

Babu Sekaran
Babu Sekaran

Reputation: 4239

Karate has hooks which can be used to address this clean up activity

Especially look for afterScenario configuration which can be helpful for implementing what needs to happen once the scenario is completed/failed.

This should have driver variable alive if it was properly initialized in your scenario. You can use that to implement any post action steps.

eg:

* configure afterScenario = 
 """ 
  function(){ 
   driver.click('input[name=logout]')
   driver.quit()
  } 
 """

Upvotes: 1

Related Questions