I'm figuring what is in Karate testing the best practice to reuse some features containing selenium steps in other features. In other words I'd like to use some scenarios containing the web browsing part and recall them in other features.
This is important from my point of view for:
- keeping together the selenium parts that otherwise the will be spread in all the features
- having one single point in case something changes in the web ui (a selector, etc)
I've tried defining a feature "A" that:
- sets the url to open with the browser (in a variable, let's say my_url)
- calls a scenario in a feature B
The feature "B" opens the url in a browser and does something, for example clicks on a button and waits for a div:
Given driver my_url
When waitForEnabled(<button selector>).click()
Then match waitFor(<div selector>).text == 'Signing complete'
The problem with this solution is that running the feature A, it calls the feature B and it works all fine but it doesn't close the webdriver at the end of the feature. Probably using a hook, closing the webdriver after the scenario in feature B, can be a solution but I'm not sure that is the best practice to do it.
I tried launching the feature in my IDE (IntelliJ Idea), not with maven.
So have you tried other solutions for this? Have you hints/tips to suggest?