cancel
Showing results for 
Search instead for 
Did you mean: 

Parametarize iterations from excel in BDD Scenario Outline

SOLVED
New Contributor

Parametarize iterations from excel in BDD Scenario Outline

How can I read data from excel and parametarize in BDD Scenario Outline, using Javascript

1 ACCEPTED SOLUTION

Accepted Solutions
Community Leader

Re: Parametarize iterations from excel in BDD Scenario Outline

Yo Durga,

 

I did not understand your algorithm corectly (If You want You can write here mofe specification) and i think I can help You write this script.

From this informations that i already know i think You can:

1) You can ready currently running "Count" variable by using:
https://support.smartbear.com/testcomplete/docs/reference/project-objects/project/testitem/count.htm...

2) If You want to have data like "How many rows i need to iterate" and use it in more than one test script then use this Project variables:

https://support.smartbear.com/testcomplete/docs/testing-with/variables/collections/project-and-proje...

 

3) "But as I have 100's of records and I want to set multiple iterations for scenario based on external file records (Excel). "

 

Read all records -> put it inside object -> save as Project Variable (if needed) -> Use objects keys to identificate which of excel records i am runing from excel in loop.

 

Or You can use "OnstartEvent"/"OnEndEvent":

https://support.smartbear.com/testcomplete/docs/reference/events/index.html

 

To iterate all keys from object in Js use this solution:

for (const [key, value] of Object.entries(objParametrowDoZaznaczenia)) {
// custom actions
}

 

View solution in original post

4 REPLIES 4
Community Leader

Re: Parametarize iterations from excel in BDD Scenario Outline

Hi durgasreedhar

 

If You write scenariu in BDD You can use params and call it within callback function inside current test step:

 

https://support.smartbear.com/testcomplete/docs/bdd/parameterize.html

 

its all about binding values to current function"

 

https://support.smartbear.com/testcomplete/docs/bdd/binding.html

 

So if You want to get params values from excel file You can add params in external unit by using //USEUNIT or require.


Inside external file use Excel file as external data sources:

 

https://support.smartbear.com/testcomplete/docs/testing-with/advanced/working-with-external-data-sou...

 

I hope this will help You.

New Contributor

Re: Parametarize iterations from excel in BDD Scenario Outline

Hi Wamboo,

Thank you for the info. I can set the parameterization from external file.

But I have scenario like...

Scenario:

1. Open the application

2. Login with "Username" and "Password

3. And so some actions in application

4. Close the application

I could have used Example for multiple iterations to run scenario if there were limited records. But as I have 100's of records and I want to set multiple iterations for scenario based on external file records (Excel). 

Can I use any annotations/tags /Beforescenario/loops to set multiple iterations for a scenario based on excelfile records.

 

 

Community Leader

Re: Parametarize iterations from excel in BDD Scenario Outline

Yo Durga,

 

I did not understand your algorithm corectly (If You want You can write here mofe specification) and i think I can help You write this script.

From this informations that i already know i think You can:

1) You can ready currently running "Count" variable by using:
https://support.smartbear.com/testcomplete/docs/reference/project-objects/project/testitem/count.htm...

2) If You want to have data like "How many rows i need to iterate" and use it in more than one test script then use this Project variables:

https://support.smartbear.com/testcomplete/docs/testing-with/variables/collections/project-and-proje...

 

3) "But as I have 100's of records and I want to set multiple iterations for scenario based on external file records (Excel). "

 

Read all records -> put it inside object -> save as Project Variable (if needed) -> Use objects keys to identificate which of excel records i am runing from excel in loop.

 

Or You can use "OnstartEvent"/"OnEndEvent":

https://support.smartbear.com/testcomplete/docs/reference/events/index.html

 

To iterate all keys from object in Js use this solution:

for (const [key, value] of Object.entries(objParametrowDoZaznaczenia)) {
// custom actions
}

 

View solution in original post

Community Manager

Re: Parametarize iterations from excel in BDD Scenario Outline

Thanks for the help, Wamboo!

 

@durgasreedhar, is it what you were looking for?

 

 

---------
Tanya Gorbunova
SmartBear Community Manager

Did my reply answer your question? Give Kudos or Accept it as a Solution to help others.↓↓↓↓↓
New Here?
Join us and watch the welcome video:
Watch the new Interview
Top Kudoed Authors