I am testing various components of my website and to test each component there is a pre-requisite that user must be logged in. When user login to website web server creates the cookie in the browser which then allow the user to access those components/pages. Now to test each component, for which I am writing several scenarios, I am writing login code every time in the scenarios because whenever my scenarios starts using the following line
@tag
Feature: User List
I want to use this template for my user list
@tag1
Scenario: Login failure error when wrong credentials
Given driver 'https://mywebsite.com/login'
When input("input[name='session[username_or_email]']", 'hello')
When input("input[name='session[password]']", ['asasas', Key.ENTER], 100)
When click('div[role=button]')
Then match html('#user-list') contains 'User Details'
#THEN REST OF THE UI TEST
I have to repeat that login code in each feature file so that I can test my rest of the page. My requirement is when I run my login feature I have to store and retain the cookie when I execute the next scenarios. How do I do that without calling the login feature or login code again and again?
Using Karate core I have used karate single call feature in the karate config which allows me to set the HTTP headers and cookie which get used in the subsequent request so it was not an issue. Can I do something like that in the Karate UI? Any pointer towards the correct direction will be really appreciated.