[TechCorner Challenge #14] Filtering data retrieved from a DataSource
Hi ReadyAPI Community!
We’ve prepared an interesting task for you to solve today! Check out the participation rules and the TechCorner Leaderboard here.
Imagine that you are working with an app for setting up online conferences, and you need to filter data based on certain criteria. In our case - the location of an online conference participant.
Task: Create a script that will filter data retrieved from a DataSource
Difficulty:
Here’s what your script should do:
1. Take an item in a DataSourse and check if it matches the criteria.
2. If it does, run the test. If it doesn't - skip the item.
The Excel file to be used as a DataSource is attached below.
Condition: Run the test only when participants of an online user conference are located in Boston.
Resources: Here are some examples of working with DataSources in Groovy scripts: https://support.smartbear.com/readyapi/docs/testing/scripts/samples/data.html
The full description of the class - here you can find all the properties and methods that the class has:
https://support.smartbear.com/readyapi/apidocs/pro/DefaultPackage/WsdlDataSourceTestStep.html
Good luck!
Task: Create a script that will filter data retrieved from a DataSource
This is a solution created for [TechCorner Challenge #14]
sonya_m :
So, i have updated the script in order to meet the criteria, please give it a try:
def Participant_Location = context.expand( '${DataSource#Participant_Location}' ) if(Participant_Location.toLowerCase() == "boston"){ testRunner.testCase.getTestStepByName("Register User").run(testRunner, context); testRunner.testCase.getTestStepByName("Buy a Ticket").run(testRunner, context); } else{ // Disabling them in order them not to run testRunner.testCase.getTestStepByName("Register User").setDisabled(true) testRunner.testCase.getTestStepByName("Buy a Ticket").setDisabled(true) }