Changing the values of a variable in a scenario script when used again later in a test run
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Changing the values of a variable in a scenario script when used again later in a test run
Hi there, I'm not sure if this has been asked before but couldn't find anything in the community or in the documentation for what I'm looking to do.
I'm looking to run a Login BDD scenario I have made which has a Login script that takes projects variables to log the user in. However, I want to be able to run this script twice in one test run, so log user A in do some stuff and logout, then log user B in and do some stuff. I was looking to do this by including my login scenario twice within my execution plan. Is it possible to be able to change what project variables the scenario/script will use later in the execution plan to be able to log the second user in?
Thank you for any help 🙂
- Labels:
-
BDD Tests
-
Variables
-
Web Testing
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
If it's BDD, then you want to use Examples,
Feature: User is able to successfully add an item to cart on the SmartStore website
Scenario Outline: Add item to cart and verify price (data-driven test)
Given I have launched the website "https://services.smartbear.com/samples/TestComplete14/smartstore/"
When I search for item <item>
And I navigate to the Product page
And I add the item to the cart
Then the item <item> must be added to cart
And price should equal <price>
Examples:
| item | price |
| "Soccer Football" | "$59.90" |
| "Airypods" | "$1,014.00" |
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
@rraghvani, I see, so if I was to use the examples and ran the scenario at the beginning of the execution plan and used the item "Soccer Football" and then towards the end of the execution plan I ran this scenario again would it then use the "Airypods" item next?
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Cucumber will run all scenario examples automatically - you would not have to run the scenario again. Additionally, you can use tags to help organize your run criteria [see here].
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
More information is provided here https://cucumber.io/docs/gherkin/reference/#examples
Whenever Scenario Outline: Add item to cart and verify price (data-driven test) is called, it will be run twice - one for "Soccer Football" and the other for "Airypods".
