1

We have automated hundreds of API tests with Karate in the last couple of months and it is a great framework! Our teams are really impressed with it.

I am doing a poc for karate UI and need some inputs in resolving the issue that I am facing. I use karate standalone jar and on 0.9.6.RC4 and have the following configuration:

karate-config.js:

karate.configure ('driver', { type: 'chrome', showDriverLog: false, httpConfig: { readTimeout: 120000 }) karate.callSingle('classpath:ui/login.feature')

Feature A:

Scenario 1: When click('something')

When I run the test, login.feature logs the user in. The syntax (driver.url, click, input etc) within login.feature is fine.

However I get this error when scenario in Feature A runs : "click" is not defined in at line number 1

By including the login feature call in the background and removing the callSingle from karate-config.js as shown below, everything works fine:

karate-config.js:

karate.configure ('driver', { type: 'chrome', showDriverLog: false, httpConfig: { readTimeout: 120000 })

Feature A:

Background:

callonce read('classpath:ui/login.feature') Scenario 1: When click('something')

I only want to login once and run all features (even for parallel execution) and logout to save time. Is this the right approach or am I doing something wrong? This seems to work for the API world where we call the auth.feature just once from the karate-config.js

Sara_N
  • 33
  • 1
  • 4
  • please read the linked answer carefully. if it doesn't answer your question, do consider contributing code. `callonce` and `callSingle` are not supported for `driver`. I suggest you use `callSingle`, get an auth token via a REST API and then use the cookies technique mentioned here: https://github.com/intuit/karate/tree/develop/karate-core#hybrid-tests – Peter Thomas Aug 18 '20 at 03:49
  • 1
    Thanks for your response and the links. We are not able to go the hybrid route yet for the auth because of some limitations. But I am going to be leveraging the API to do the data setup for browser tests. I did review the other answer and it looks like the call to the top feature needs to be included in each of our features for now. I do not understand the Java world or have a development background to contribute to your awesome framework. Wish I did. Thanks again for Karate. It had made our lives so much easier. – Sara_N Aug 18 '20 at 15:41
  • great :) let me say that Karate encourages parallel execution, which is why it is designed this way. see this Docker demo. this is why each `Scenario` should be independent: https://twitter.com/ptrthomas/status/1159295560794308609 – Peter Thomas Aug 18 '20 at 15:46
  • Oh yes, I can't wait to get my hands on this. – Sara_N Aug 19 '20 at 13:15

0 Answers0