1

I have recently implemented UI automation along with my API test automation (both in Karate). It is working now with minor issue - the browser is getting closed automatically after the script is executed completely. Is there a way in Karate to either close or retain the browser opened? Thank you!

Scenario: Get UI - Download
   Given url 'https://test01/v1/doc/env/
   And headers headers1
   When method get
   Then status 200
   * def env = response.url

   Given driver env
   And click('{button}Proceed')
   And click('{span}Start')
   And click('{span}Required - GSA)
   And click('{span}Required - GSB')
   And click('{span}Required - GSC')
   And click('{span}Required - GSD')
   And click('{span}Required - GSE')
   And click('{span}Required - GSF')
   And click('{span}Required - GSG')
   And click('{span}Required - GSH')
Drachir
  • 59
  • 7

2 Answers2

2

There is also:

* configure robot = { autoClose: false }

which worked for me on a desktop application.

Nick
  • 21
  • 4
1

This is by design. You can try add a * karate.stop() line at the end, but this is definitely not recommended for "normal" test scripts.

Also note that there is an option to step-through and debug tests: https://twitter.com/KarateDSL/status/1252817691963830272

EDIT: for those trying to "re-use" the browser across multiple flows, pleaser read this answer that explains why Karate is designed the way it is: https://stackoverflow.com/a/62325328/143475

Peter Thomas
  • 54,465
  • 21
  • 84
  • 248
  • 1
    thanks for clarifying that this the expected behaviour of the tool as per the design. More power! – Drachir Apr 28 '20 at 10:45
  • Hi Peter, we have scenario to search multiple values in the search bar and see if they are getting returned or not. We've tried examples, scenario outline in Karate UI but it didn't work. We tried tables and it worked; however, the cucumber report doesn't show all iterations as different scenario which is going to be a problem when we send the report. If we go back to using examples, scenario outline; how can we keep the browser open to continue searching for other values? Thanks in advance! – Drachir Apr 21 '21 at 23:49
  • @Drachir which version of karate ? if you are talking 3rd party cucumber reports, they don't support "nested" calls to features, yes. so my recommendation is upgrade and use the karate built-in reports (or contribute to improve them). we will never support re-using a driver across top-level scenarios. you can explore using the Java API directly and managing the browser yourself: https://twitter.com/KarateDSL/status/1353969718730788865 – Peter Thomas Apr 22 '21 at 03:39
  • 1
    Hi @Peter Thomas, we are using the older version of karate(0.9.6). Will try to update and see. – Drachir Apr 22 '21 at 04:47