Can someone help to write Test Scenario in Gherkins format

Can someone help me to write a test scenario for the following in Gherkins format as matter of urgency:

Prerequisite :
Download the Android app from the Play Store

  1. Open the app
  2. Navigate to Shop bottom navigation
  3. Select Men > Clothing > Knitwear category (In case this category is unavailable on the app please select any category which has more than 7 items in the list)
  4. Select the 7th item displayed
  5. Select a colour if any are available
  6. Add to Bag
  7. Snack bar
  8. View Bag
  • Write the scenario in a feature file (Gherkins format)
  • Step definitions (Can have locators and methods )
  • Preferably Using Java and Appium or an alternative test automation framework
2 Likes

Hi Daniel,
I’m not sure why this is of urgency or who it is for but what I would say is that if you are working as part of a team currently and this scenario is for that project then you should be as a team coming up with scenarios. It’s not just down to a tester/QA/SDET/or whatever people call themselves these days… to come up with and implement this stuff.

That being said, what you’ve written above is pretty much a test script and I’d avoid trying to move this as is into a scenario. A scenario implemented like this would be in an imperative style. In my experience, these types of scenarios written in that style are not only horrid to look at, but also to implement and maintain. Instead, it would help if you were looking to describe the behaviour and not the implementation in a declarative style.

I wouldn’t copy this (and I’ve not had much coffee yet so there’s lots of room for improvement) but just to give you an idea of how you might want to write this:

Scenario: A user can add an item to their bag in the Android App
Given I am on the Store
When I choose an item to add to the bag
Then the item should be added to my bag
Scenario: A user can view an item they've already added to their shopping bag in the Android App
Given I am on the Store
And I have already chosen an item to add to the bag
When I view my bag
Then I should see the item that was added

As for backing steps/step definitions, I can’t write these for you because I don’t use Java or Appium and don’t have access to the store app you refer to. You’d again be better off speaking to your team/interviewer/teacher or whatever and ask questions if you are unsure.

Also these books by Seb Rose and Gaspar Nagy are awesome - I’d check them out. They will help on formulating and implementing scenarios much better than I’ve done above https://bddbooks.com

All the best,
Viv

3 Likes

Hi Daniel,

The scenarios from Viv are pretty much what I would have suggested also.

The most important point is perhaps that you want to write WHAT you want to do, not HOW you would perform the scenario. This helps you in several ways, including clarity for yourself, communication with business-oriented folks (such as PO, BA), and to keep the maintenance effort low.

You could leave being on the store implicit if that applies for all tests.

Good luck,

Martin

2 Likes

Thank you so much. This really helps

2 Likes

Sorry forgot to include the App. The app is Cotton Traders

1 Like

Hey Daniel,

Thank you for sharing the app you are trying to automate. I don’t have the time at the moment to install and explore this app to provide you with any code snippets to automate those scenarios.

I’d suggest though that you search online about ways to write test automation for Android apps. I’m sure there will be lots of different ways to achieve this and plenty of examples for you to consider.

If you are unsure, again I’d go back to your team or the person asking you to do this task if it’s an assignment or interview task and ask for help if you need it.

Good luck,
Viv

1 Like

Here is a read up and break down of Gherkin if you wanted to take a read through.

The only thing I would nitpic about the others responses (cause they’re great) is, I stay away from using the word “I”. I would input the client or end user to narrow the scope to who is actually using this process. Unless you are the end user of this story.

1 Like

I would start at a higher level, the Feature level and break into the positive and negative Scenarios. This is where PM, DEV and QE determine what is valid and what will be delivered within the sprint.

@addToCart
Feature: Add to Cart

Scenario: Add a single item to cart
Scenario: Add multiple different items
Scenario: Add the same item multiple times
Scenario: Add the same item until you reach the maximum available
Scenario: Add an item that is sold out